Skip to content

Commit 12ea971

Browse files
committed
refactor(io_tokio): get rid of *_bounded functions
1 parent 1e5274b commit 12ea971

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

src/toxcore/io_tokio.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
33
use std::fmt::Debug;
44
use std::io::{Error as IoError};
5-
use std::time::Duration;
65

76
use futures::{Future, Sink, Stream};
8-
use tokio::util::FutureExt;
9-
use tokio::timer::timeout::Error as TimeoutError;
107

118
/// A convenience typedef around a `Future` whose error component is `io::Error`
129
pub type IoFuture<T> = Box<Future<Item = T, Error = IoError> + Send>;
@@ -24,14 +21,6 @@ pub fn send_to<T: Send + 'static, Tx, E: Debug>(tx: &Tx, v: T) -> impl Future<It
2421
.map(|_tx| ()) // ignore tx because it was cloned
2522
}
2623

27-
/// Send item to a sink using reference with timeout
28-
pub fn send_to_bounded<T: Send + 'static, Tx, E: Debug>(tx: &Tx, v: T, timeout: Duration) -> impl Future<Item=(), Error=TimeoutError<E>> + Send
29-
where Tx: Sink<SinkItem = T, SinkError = E> + Send + Clone + 'static
30-
{
31-
send_to(tx, v)
32-
.timeout(timeout)
33-
}
34-
3524
/// Send item to a sink using reference
3625
pub fn send_all_to<T: Send + 'static, S, Tx, E: Debug>(tx: &Tx, s: S) -> impl Future<Item=(), Error=E> + Send
3726
where S: Stream<Item = T, Error = E> + Send + 'static,
@@ -43,11 +32,3 @@ pub fn send_all_to<T: Send + 'static, S, Tx, E: Debug>(tx: &Tx, s: S) -> impl Fu
4332
.map(|_tx| ()) // ignore tx because it was cloned
4433
}
4534

46-
/// Send item to a sink using reference with timeout
47-
pub fn send_all_to_bounded<T: Send + 'static, S, Tx, E: Debug>(tx: &Tx, s: S, timeout: Duration) -> impl Future<Item=(), Error=TimeoutError<E>> + Send
48-
where S: Stream<Item = T, Error = E> + Send + 'static,
49-
Tx: Sink<SinkItem = T, SinkError = E> + Send + Clone + 'static
50-
{
51-
send_all_to(tx, s)
52-
.timeout(timeout)
53-
}

src/toxcore/tcp/server/client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::time::{Instant, Duration};
1616

1717
use futures::Future;
1818
use futures::sync::mpsc;
19+
use tokio::util::FutureExt;
1920

2021
/// Interval in seconds for sending TCP PingRequest
2122
pub const TCP_PING_FREQUENCY: u64 = 30;
@@ -128,7 +129,7 @@ impl Client {
128129
/** Send a packet. This method does not ignore IO error
129130
*/
130131
fn send(&self, packet: Packet) -> impl Future<Item = (), Error = Error> + Send {
131-
send_to_bounded(&self.tx, packet, Duration::from_secs(TCP_SEND_TIMEOUT)).map_err(|e|
132+
send_to(&self.tx, packet).timeout(Duration::from_secs(TCP_SEND_TIMEOUT)).map_err(|e|
132133
Error::new(ErrorKind::Other,
133134
format!("Failed to send packet: {:?}", e)
134135
))

0 commit comments

Comments
 (0)