impl From<S> for bincode::Transport<S>

This commit is contained in:
Tim Kuehn
2018-10-18 00:24:08 -07:00
parent 6d396520f4
commit 8847330dbe

View File

@@ -118,12 +118,18 @@ where
Item: for<'de> Deserialize<'de>,
SinkItem: Serialize,
{
Transport {
inner: Compat::new(AsyncBincodeStream::from(io).for_async()),
}
Transport::from(io)
}
impl<S, Item, SinkItem> From<S> for Transport<S, Item, SinkItem> {
fn from(inner: S) -> Self {
Transport {
inner: Compat::new(AsyncBincodeStream::from(inner).for_async()),
}
}
}
/// Connects to `addr`, wrapping the connection in a bincode transport.
pub async fn connect<Item, SinkItem>(addr: &SocketAddr) -> io::Result<Transport<TcpStream, Item, SinkItem>>
where