pub struct Transport<'a, S: StreamSocket> { /* private fields */ }
Expand description
Transport is thing that provides buffered I/O for stream sockets
This is usually passed in all the Protocol
handler methods. But in
case you manipulate the transport by some external methods (like the
one stored in Arc<Mutex<Stream>>
you may wish to use Stream::transport
or Persistent::transport
methods to manipulate tranpsport. Just remember
to wake up the state machine after manipulating buffers of transport.
Implementations§
Source§impl<'a, S: StreamSocket> Transport<'a, S>
impl<'a, S: StreamSocket> Transport<'a, S>
Sourcepub fn socket<'x>(&'x mut self) -> &'x mut S
pub fn socket<'x>(&'x mut self) -> &'x mut S
Get the reference to the underlying stream
It’s here so you can inspect socket state or tune it. For example you might want to set TCP_CORK option or find out peer or local address.
Reading from and writing to a socket directly may lead to unexpected
behavior. Use input()
and output()
buffers instead.
Sourcepub fn input<'x>(&'x mut self) -> &'x mut Buf ⓘ
pub fn input<'x>(&'x mut self) -> &'x mut Buf ⓘ
Get a reference to the input buffer
It’s expected that you only read and consume()
bytes from buffer
but never write.