From 13c30843a39bd399985734671754eb02d4538cd0 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 11 May 2020 22:10:34 +0200 Subject: [PATCH] Introduce ClientCodec, ServerCodec type aliases --- examples/consumer.rs | 2 +- src/packets.rs | 3 +++ src/peer.rs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/consumer.rs b/examples/consumer.rs index a56672b..739dbf8 100644 --- a/examples/consumer.rs +++ b/examples/consumer.rs @@ -6,7 +6,7 @@ use futures::SinkExt; #[tokio::main] async fn main() -> Result<(), Box> { let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, - packets::Codec::::standard()); + packets::ClientCodec::standard()); frames.send(packets::C2S::Connect(Value::from("producer-consumer-example").wrap())).await?; Ok(()) } diff --git a/src/packets.rs b/src/packets.rs index 963f48d..fcc4d84 100644 --- a/src/packets.rs +++ b/src/packets.rs @@ -103,6 +103,9 @@ pub struct Codec { ph_out: PhantomData, } +pub type ServerCodec = Codec; +pub type ClientCodec = Codec; + impl Codec { pub fn new(codec: value::Codec) -> Self { Codec { codec, ph_in: PhantomData, ph_out: PhantomData } diff --git a/src/peer.rs b/src/peer.rs index 89b1ad7..9c9e71a 100644 --- a/src/peer.rs +++ b/src/peer.rs @@ -20,7 +20,7 @@ pub struct Peer { id: ConnId, tx: UnboundedSender, rx: UnboundedReceiver, - frames: Framed>, + frames: Framed, space: Option, }