tokio_proto/streaming/multiplex/
mod.rs1use std::io;
6use futures::{Stream, Sink, Async};
7use tokio_core::io as old_io;
8use tokio_io as new_io;
9
10mod frame_buf;
11
12mod client;
13pub use self::client::ClientProto;
14
15mod server;
16pub use self::server::ServerProto;
17
18mod frame;
19pub use self::frame::Frame;
20
21
22pub mod advanced;
23
24pub type RequestId = u64;
26
27#[derive(Debug)]
32pub struct StreamingMultiplex<B>(B);
33
34pub trait Transport<ReadBody>: 'static +
38 Stream<Error = io::Error> +
39 Sink<SinkError = io::Error>
40{
41 fn tick(&mut self) {}
47
48 fn cancel(&mut self, request_id: RequestId) -> io::Result<()> {
50 drop(request_id);
51 Ok(())
52 }
53
54 fn poll_write_body(&mut self, id: RequestId) -> Async<()> {
57 drop(id);
58 Async::Ready(())
59 }
60
61 fn dispatching_body(&mut self, id: RequestId, body: &ReadBody) {
64 drop(id);
65 drop(body);
66 }
67}
68
69impl<T, C, ReadBody> Transport<ReadBody> for old_io::Framed<T,C>
70 where T: old_io::Io + 'static,
71 C: old_io::Codec + 'static,
72{}
73
74impl<T, C, ReadBody> Transport<ReadBody> for new_io::codec::Framed<T,C>
75 where T: new_io::AsyncRead + new_io::AsyncWrite + 'static,
76 C: new_io::codec::Encoder<Error=io::Error> +
77 new_io::codec::Decoder<Error=io::Error> + 'static,
78{}