Skip to content

Commit 94568ba

Browse files
committed
refactor BoxResult
1 parent 6262199 commit 94568ba

File tree

9 files changed

+9
-21
lines changed

9 files changed

+9
-21
lines changed

src/client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use crate::{
3030
};
3131
use mio::net::TcpStream;
3232
use std::{
33-
error::Error,
3433
net::{IpAddr, Shutdown, ToSocketAddrs},
3534
sync::{
3635
atomic::{AtomicBool, Ordering},
@@ -41,7 +40,7 @@ use std::{
4140
time::{Duration, SystemTime, UNIX_EPOCH},
4241
};
4342

44-
type BoxResult<T> = Result<T, Box<dyn Error>>;
43+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
4544

4645
/// when false, the system is shutting down
4746
static ALIVE: AtomicBool = AtomicBool::new(true);

src/protocol/communication.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ use std::time::Duration;
2424
use mio::net::TcpStream;
2525
use mio::{Events, Interest, Poll, Token};
2626

27-
use std::error::Error;
28-
type BoxResult<T> = Result<T, Box<dyn Error>>;
27+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
2928

3029
/// how long to wait for keepalive events
3130
// the communications channels typically exchange data every second, so 2s is reasonable to avoid excess noise

src/protocol/messaging.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
* along with rperf. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
use std::error::Error;
22-
type BoxResult<T> = Result<T, Box<dyn Error>>;
21+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
2322

2423
/// prepares a message used to tell the server to begin operations
2524
pub fn prepare_begin() -> serde_json::Value {

src/protocol/results.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
2323

2424
use serde::{Deserialize, Serialize};
2525

26-
use std::error::Error;
27-
type BoxResult<T> = Result<T, Box<dyn Error>>;
26+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
2827

2928
/* This module contains structures used to represent and collect the results of tests.
3029
* Since everything is basically just a data-container with representation methods,

src/server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* along with rperf. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
use std::error::Error;
2221
use std::io;
2322
use std::net::{Shutdown, SocketAddr};
2423
use std::sync::atomic::{AtomicBool, AtomicU16, Ordering};
@@ -36,7 +35,7 @@ use crate::protocol::messaging::{prepare_connect, prepare_connect_ready};
3635
use crate::protocol::results::ServerDoneResult;
3736
use crate::stream::{tcp, udp, TestStream};
3837

39-
type BoxResult<T> = Result<T, Box<dyn Error>>;
38+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
4039

4140
const POLL_TIMEOUT: Duration = Duration::from_millis(500);
4241

src/stream/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
pub mod tcp;
2222
pub mod udp;
2323

24-
use std::error::Error;
25-
type BoxResult<T> = Result<T, Box<dyn Error>>;
24+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
2625

2726
pub const INTERVAL: std::time::Duration = std::time::Duration::from_secs(1);
2827

src/stream/tcp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ use crate::protocol::results::{get_unix_timestamp, IntervalResult, TcpReceiveRes
2424

2525
use super::{parse_port_spec, TestStream, INTERVAL};
2626

27-
use std::error::Error;
28-
type BoxResult<T> = Result<T, Box<dyn Error>>;
27+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
2928

3029
pub const TEST_HEADER_SIZE: usize = 16;
3130

src/stream/udp.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
* along with rperf. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
use std::error::Error;
22-
2321
use nix::sys::socket::{setsockopt, sockopt::RcvBuf, sockopt::SndBuf};
2422

2523
use crate::protocol::results::{get_unix_timestamp, IntervalResult, UdpReceiveResult, UdpSendResult};
2624

2725
use super::{parse_port_spec, TestStream, INTERVAL};
2826

29-
type BoxResult<T> = Result<T, Box<dyn Error>>;
27+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
3028

3129
pub const TEST_HEADER_SIZE: u16 = 36;
3230
const UDP_HEADER_SIZE: u16 = 8;

src/utils/cpu_affinity.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
* along with rperf. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
extern crate core_affinity;
22-
23-
use std::error::Error;
24-
type BoxResult<T> = Result<T, Box<dyn Error>>;
21+
type BoxResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
2522

2623
pub struct CpuAffinityManager {
2724
enabled_cores: Vec<core_affinity::CoreId>,

0 commit comments

Comments
 (0)