Struct ntex_io::IoBoxed

source ·
pub struct IoBoxed(/* private fields */);
Expand description

Boxed Io object with erased filter type

Implementations§

source§

impl IoBoxed

source

pub fn take(&mut self) -> Self

Clone current io object.

Current io object becomes closed.

Methods from Deref<Target = Io<Sealed>>§

source

pub fn set_memory_pool(&self, pool: PoolRef)

Set memory pool

source

pub fn set_disconnect_timeout(&self, timeout: Seconds)

Set io disconnect timeout in millis

source

pub fn get_ref(&self) -> IoRef

Get instance of IoRef

source

pub fn filter(&self) -> &F

Get referece to a filter

source

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

Read incoming io stream and decode codec item.

source

pub async fn read_ready(&self) -> Result<Option<()>>

Wait until read becomes ready.

source

pub fn pause(&self)

Pause read task

source

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

Encode item, send to the peer. Fully flush write buffer.

source

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

Wake write task and instruct to flush data.

This is async version of .poll_flush() method.

source

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

Gracefully shutdown io stream

source

pub fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<Result<Option<()>>>

Polls for read readiness.

If the io stream is not currently ready for reading, this method will store a clone of the Waker from the provided Context. When the io stream becomes ready for reading, Waker::wake will be called on the waker.

Return value The function returns:

Poll::Pending if the io stream is not ready for reading. Poll::Ready(Ok(Some(())))) if the io stream is ready for reading. Poll::Ready(Ok(None)) if io stream is disconnected Some(Poll::Ready(Err(e))) if an error is encountered.

source

pub fn poll_recv<U>( &self, codec: &U, cx: &mut Context<'_> ) -> Poll<Result<U::Item, RecvError<U>>>
where U: Decoder,

Decode codec item from incoming bytes stream.

Wake read task and request to read more data if data is not enough for decoding. If error get returned this method does not register waker for later wake up action.

source

pub fn poll_flush(&self, cx: &mut Context<'_>, full: bool) -> Poll<Result<()>>

Wake write task and instruct to flush data.

If full is true then wake up dispatcher when all data is flushed otherwise wake up when size of write buffer is lower than buffer max size.

source

pub fn poll_shutdown(&self, cx: &mut Context<'_>) -> Poll<Result<()>>

Gracefully shutdown io stream

source

pub fn poll_read_pause(&self, cx: &mut Context<'_>) -> Poll<IoStatusUpdate>

Pause read task

Returns status updates

source

pub fn poll_status_update(&self, cx: &mut Context<'_>) -> Poll<IoStatusUpdate>

Wait for status updates

source

pub fn poll_dispatch(&self, cx: &mut Context<'_>)

Register dispatch task

Methods from Deref<Target = IoRef>§

source

pub fn memory_pool(&self) -> PoolRef

Get memory pool

source

pub fn is_closed(&self) -> bool

Check if io stream is closed

source

pub fn is_wr_backpressure(&self) -> bool

Check if write back-pressure is enabled

source

pub fn wake(&self)

Wake dispatcher task

source

pub fn close(&self)

Gracefully close connection

Notify dispatcher and initiate io stream shutdown process.

source

pub fn force_close(&self)

Force close connection

Dispatcher does not wait for uncompleted responses. Io stream get terminated without any graceful period.

source

pub fn want_shutdown(&self)

Gracefully shutdown io stream

source

pub fn query<T: 'static>(&self) -> QueryItem<T>

Query filter specific data

source

pub fn encode<U>( &self, item: U::Item, codec: &U ) -> Result<(), <U as Encoder>::Error>
where U: Encoder,

Encode and write item to a buffer and wake up write task

source

pub fn decode<U>( &self, codec: &U ) -> Result<Option<<U as Decoder>::Item>, <U as Decoder>::Error>
where U: Decoder,

Attempts to decode a frame from the read buffer

source

pub fn decode_item<U>( &self, codec: &U ) -> Result<Decoded<<U as Decoder>::Item>, <U as Decoder>::Error>
where U: Decoder,

Attempts to decode a frame from the read buffer

source

pub fn write(&self, src: &[u8]) -> Result<()>

Write bytes to a buffer and wake up write task

source

pub fn with_buf<F, R>(&self, f: F) -> Result<R>
where F: FnOnce(&WriteBuf<'_>) -> R,

Get access to write buffer

source

pub fn with_write_buf<F, R>(&self, f: F) -> Result<R>
where F: FnOnce(&mut BytesVec) -> R,

Get mut access to source write buffer

source

pub fn with_read_buf<F, R>(&self, f: F) -> R
where F: FnOnce(&mut BytesVec) -> R,

Get mut access to source read buffer

source

pub fn timer_handle(&self) -> TimerHandle

current timer handle

source

pub fn notify_timeout(&self)

wakeup dispatcher and send keep-alive error

source

pub fn start_timer(&self, timeout: Seconds) -> TimerHandle

Start timer

source

pub fn stop_timer(&self)

Stop timer

source

pub fn tag(&self) -> &'static str

Get tag

source

pub fn set_tag(&self, tag: &'static str)

Set tag

source

pub fn on_disconnect(&self) -> OnDisconnect

Notify when io stream get disconnected

Trait Implementations§

source§

impl Debug for IoBoxed

source§

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

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

impl Deref for IoBoxed

§

type Target = Io<Sealed>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<F: Filter> From<Io<F>> for IoBoxed

source§

fn from(io: Io<F>) -> Self

Converts to this type from the input type.
source§

impl From<Io<Sealed>> for IoBoxed

source§

fn from(io: Io<Sealed>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for IoBoxed

§

impl !RefUnwindSafe for IoBoxed

§

impl !Send for IoBoxed

§

impl !Sync for IoBoxed

§

impl Unpin for IoBoxed

§

impl !UnwindSafe for IoBoxed

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

§

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

§

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.