rotor_stream/
transport.rs

1use {Buf, Transport, StreamSocket};
2
3
4impl<'a, S: StreamSocket> Transport<'a, S> {
5    /// Get the reference to the underlying stream
6    ///
7    /// It's here so you can inspect socket state or tune it. For example you
8    /// might want to set TCP_CORK option or find out peer or local address.
9    ///
10    /// Reading from and writing to a socket directly may lead to unexpected
11    /// behavior. Use `input()` and `output()` buffers instead.
12    pub fn socket<'x>(&'x mut self) -> &'x mut S {
13        self.sock
14    }
15    /// Get a reference to the input buffer
16    ///
17    /// It's expected that you only read and `consume()` bytes from buffer
18    /// but never write.
19    pub fn input<'x>(&'x mut self) -> &'x mut Buf {
20        self.inbuf
21    }
22    /// Get a reference to the output buffer
23    ///
24    /// It's expected that you only inspect and write to the output buffer
25    /// but never `consume()`
26    pub fn output<'x>(&'x mut self) -> &'x mut Buf {
27        self.outbuf
28    }
29    /// Get a references to both buffers (input, output)
30    ///
31    /// It's useful when you want to pass both things somewhere along the
32    /// chain of calls. See `input()` and `output()` methods for more comments
33    /// on buffer usage
34    pub fn buffers<'x>(&'x mut self) -> (&'x mut Buf, &'x mut Buf) {
35        (self.inbuf, self.outbuf)
36    }
37}