Struct Transport

Source
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>

Source

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.

Source

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.

Source

pub fn output<'x>(&'x mut self) -> &'x mut Buf

Get a reference to the output buffer

It’s expected that you only inspect and write to the output buffer but never consume()

Source

pub fn buffers<'x>(&'x mut self) -> (&'x mut Buf, &'x mut Buf)

Get a references to both buffers (input, output)

It’s useful when you want to pass both things somewhere along the chain of calls. See input() and output() methods for more comments on buffer usage

Auto Trait Implementations§

§

impl<'a, S> Freeze for Transport<'a, S>

§

impl<'a, S> RefUnwindSafe for Transport<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for Transport<'a, S>
where S: Send,

§

impl<'a, S> Sync for Transport<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for Transport<'a, S>

§

impl<'a, S> !UnwindSafe for Transport<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.