Skip to main content

IoBoxed

Struct 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 get_ref(&self) -> IoRef

Get an instance of IoRef.

Source

pub fn take(&self) -> Self

Takes the current I/O object.

After this call, the I/O object is no longer valid for use.

Source

pub fn set_config<T: Into<SharedCfg>>(&self, cfg: T)

Updates the shared I/O configuration.

Source

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

Reads from the incoming I/O stream and decodes a codec item.

Source

pub async fn read(&self, dst: &mut [u8]) -> Result<()>

Reads bytes from this I/O stream into the specified buffer.

If there is not enough data available, waits for incoming data.

Source

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

Waits until the I/O stream is ready for reading.

Source

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

Waits until the I/O stream receives new data.

Source

pub fn pause(&self)

Pauses the read task.

Source

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

Encodes an item and sends it to the peer, fully flushing the write buffer.

Source

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

Wakes the write task and requests a flush of buffered data.

This is the async version of .poll_flush() method.

Source

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

Gracefully shuts down the I/O stream.

Source

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

Polls for read readiness.

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

§Returns

The function returns:

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

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

Polls the I/O stream for availability of incoming data.

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_recv_decode<U>( &self, codec: &U, cx: &mut Context<'_>, ) -> Result<Decoded<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<()>>

Wakes the write task and instructs it to flush data.

If full is true, wakes the dispatcher when all data has been flushed; otherwise, it wakes when the write buffer size falls below the low-watermark size.

Source

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

Gracefully shuts down the I/O stream.

Source

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

Pauses the read task.

Returns status updates.

Source

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

Polls for available status updates.

Source

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

Registers a dispatch task.

Methods from Deref<Target = IoRef>§

Source

pub fn id(&self) -> Id

Gets the ID.

Source

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

Gets the I/O tag.

Source

pub fn cfg(&self) -> &IoConfig

Gets the configuration.

Source

pub fn shared(&self) -> SharedCfg

Gets the shared configuration.

Source

pub fn is_closed(&self) -> bool

Checks whether the I/O stream is closed.

Source

pub fn is_wr_backpressure(&self) -> bool

Checks whether write back-pressure is enabled.

Source

pub fn close(&self)

Gracefully closes the connection.

Initiates the I/O stream shutdown process.

Source

pub fn terminate(&self)

Force-closes the connection.

The dispatcher does not wait for incomplete responses. The I/O stream is terminated without any graceful period.

Source

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

Queries filter-specific data.

Source

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

Encodes the item into the write buffer.

Source

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

Encodes the slice into the write buffer.

Source

pub fn encode_bytes<B>(&self, src: B) -> Result<()>
where BytePage: From<B>,

Writes bytes to the write buffer.

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 send_buf(&self) -> Result<()>

Sends the write buffer to the I/O layer.

Requires the underlying runtime to implement .write(); otherwise, no action is taken.

Source

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

Get access to filter buffer

Source

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

Get mut access to read buffer

Source

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

Get mut access to source write buffer

Source

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

Get mut access to dest write buffer

Source

pub fn resize_read_buf(&self, buf: &mut BytesMut)

Make sure buffer has enough free space

Source

pub fn notify_dispatcher(&self)

Wakeup dispatcher

Source

pub fn notify_timeout(&self)

Wakeup dispatcher and send keep-alive error

Source

pub fn timer_handle(&self) -> TimerHandle

Current timer handle

Source

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

Start timer

Source

pub fn stop_timer(&self)

Stop timer

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

Source§

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<IoBoxed> for Io<Sealed>

Source§

fn from(value: IoBoxed) -> Self

Converts to this type from the input type.

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.