ntex_io

Struct Framed

source
pub struct Framed<U> { /* private fields */ }
Expand description

A unified interface to an underlying I/O object, using the Encoder and Decoder traits to encode and decode frames. Framed is heavily optimized for streaming io.

Implementations§

source§

impl<U> Framed<U>

source

pub fn new<Io>(io: Io, codec: U) -> Framed<U>
where IoBoxed: From<Io>,

Provides an interface for reading and writing to Io object, using Decode and Encode traits of codec.

source

pub fn get_io(&self) -> &IoBoxed

Returns a reference to the underlying I/O stream wrapped by Framed.

source

pub fn get_codec(&self) -> &U

Returns a reference to the underlying codec.

source

pub fn into_inner(self) -> (IoBoxed, U)

Return inner types of framed object

source§

impl<U> Framed<U>
where U: Decoder + Encoder,

source

pub async fn flush(&self, full: bool) -> Result<(), Error>

Wake write task and instruct to flush data.

This is async version of .poll_flush() method.

source

pub async fn shutdown(&self) -> Result<(), Error>

Shut down io stream

source§

impl<U> Framed<U>
where U: Decoder,

source

pub async fn recv(&self) -> Result<Option<U::Item>, Either<U::Error, Error>>

Read incoming io stream and decode codec item.

source§

impl<U> Framed<U>
where U: Encoder,

source

pub async fn send( &self, item: <U as Encoder>::Item, ) -> Result<(), Either<U::Error, Error>>

Serialize item and Write to the inner buffer

Trait Implementations§

source§

impl<U> Debug for Framed<U>
where U: Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<U> !Freeze for Framed<U>

§

impl<U> !RefUnwindSafe for Framed<U>

§

impl<U> !Send for Framed<U>

§

impl<U> !Sync for Framed<U>

§

impl<U> Unpin for Framed<U>
where U: Unpin,

§

impl<U> !UnwindSafe for Framed<U>

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.