Struct InmemoryTransport

Source
pub struct InmemoryTransport { /* private fields */ }
Expand description

Represents a Transport comprised of two inmemory channels

Implementations§

Source§

impl InmemoryTransport

Source

pub fn new(tx: Sender<Vec<u8>>, rx: Receiver<Vec<u8>>) -> Self

Creates a new transport where tx is used to send data out of the transport during try_write and rx is used to receive data into the transport during try_read.

Source

pub fn make(buffer: usize) -> (Sender<Vec<u8>>, Receiver<Vec<u8>>, Self)

Returns (incoming_tx, outgoing_rx, transport) where incoming_tx is used to send data to the transport where it will be consumed during try_read and outgoing_rx is used to receive data from the transport when it is written using try_write.

Source

pub fn pair(buffer: usize) -> (Self, Self)

Returns pair of transports that are connected such that one sends to the other and vice versa

Links two independent InmemoryTransport together by dropping their internal channels and generating new ones of buffer capacity to connect these transports.

§Note

This will drop any pre-existing data in the internal storage to avoid corruption.

Trait Implementations§

Source§

impl Debug for InmemoryTransport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Reconnectable for InmemoryTransport

Source§

fn reconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Once the underlying channels have closed, there is no way for this transport to re-establish those channels; therefore, reconnecting will fail with ErrorKind::ConnectionRefused if either underlying channel has closed.

Source§

impl Transport for InmemoryTransport

Source§

fn try_read(&self, buf: &mut [u8]) -> Result<usize>

Tries to read data from the transport into the provided buffer, returning how many bytes were read. Read more
Source§

fn try_write(&self, buf: &[u8]) -> Result<usize>

Try to write a buffer to the transport, returning how many bytes were written. Read more
Source§

fn ready<'life0, 'async_trait>( &'life0 self, interest: Interest, ) -> Pin<Box<dyn Future<Output = Result<Ready>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Waits for the transport to be ready based on the given interest, returning the ready status.

Auto Trait Implementations§

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes and produces Box<dyn Any>
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> Connector for T
where T: Transport + 'static,

Source§

type Transport = T

Type of transport produced by the connection.
Source§

fn connect<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<<T as Connector>::Transport, Error>> + Send + 'async_trait>>
where T: 'async_trait,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TransportExt for T
where T: Transport,

Source§

fn readable<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: 'async_trait,

Waits for the transport to be readable to follow up with try_read.
Source§

fn writeable<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: 'async_trait,

Waits for the transport to be writeable to follow up with try_write.
Source§

fn readable_or_writeable<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: 'async_trait,

Waits for the transport to be either readable or writeable.
Source§

fn read_exact<'life0, 'life1, 'async_trait>( &'life0 self, buf: &'life1 mut [u8], ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Reads exactly n bytes where n is the length of buf by continuing to call try_read until completed. Calls to readable are made to ensure the transport is ready. Returns the total bytes read.
Source§

fn read_to_end<'life0, 'life1, 'async_trait>( &'life0 self, buf: &'life1 mut Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Reads all bytes until EOF in this source, placing them into buf. Read more
Source§

fn read_to_string<'life0, 'life1, 'async_trait>( &'life0 self, buf: &'life1 mut String, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Reads all bytes until EOF in this source, placing them into buf. Read more
Source§

fn write_all<'life0, 'life1, 'async_trait>( &'life0 self, buf: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Writes all of buf by continuing to call try_write until completed. Calls to [writeable] are made to ensure the transport is ready.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V