pub struct Io<F = Base>(/* private fields */);Expand description
Interface object to the underlying I/O stream
Implementations§
Source§impl<F: Filter> Io<F>
impl<F: Filter> Io<F>
Sourcepub fn add_filter<U>(self, nf: U) -> Io<Layer<U, F>>where
U: FilterLayer,
pub fn add_filter<U>(self, nf: U) -> Io<Layer<U, F>>where
U: FilterLayer,
Adds a new processing layer to the current filter chain.
Sourcepub fn map_filter<U, R>(self, f: U) -> Io<R>
pub fn map_filter<U, R>(self, f: U) -> Io<R>
Wraps the current layer with a wrapper.
Source§impl<F> Io<F>
impl<F> Io<F>
Sourcepub async fn recv<U>(
&self,
codec: &U,
) -> Result<Option<U::Item>, Either<U::Error, Error>>where
U: Decoder,
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.
Sourcepub async fn read(&self, dst: &mut [u8]) -> Result<()>
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.
Sourcepub async fn read_ready(&self) -> Result<Option<()>>
pub async fn read_ready(&self) -> Result<Option<()>>
Waits until the I/O stream is ready for reading.
Sourcepub async fn read_notify(&self) -> Result<Option<()>>
pub async fn read_notify(&self) -> Result<Option<()>>
Waits until the I/O stream receives new data.
Sourcepub async fn send<U>(
&self,
item: U::Item,
codec: &U,
) -> Result<(), Either<U::Error, Error>>where
U: Encoder,
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.
Sourcepub async fn flush(&self, full: bool) -> Result<()>
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.
Sourcepub fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<Result<Option<()>>>
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::Pendingif 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.
Sourcepub fn poll_read_notify(&self, cx: &mut Context<'_>) -> Poll<Result<Option<()>>>
pub fn poll_read_notify(&self, cx: &mut Context<'_>) -> Poll<Result<Option<()>>>
Polls the I/O stream for availability of incoming data.
Sourcepub fn poll_recv<U>(
&self,
codec: &U,
cx: &mut Context<'_>,
) -> Poll<Result<U::Item, RecvError<U>>>where
U: Decoder,
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.
Sourcepub fn poll_recv_decode<U>(
&self,
codec: &U,
cx: &mut Context<'_>,
) -> Result<Decoded<U::Item>, RecvError<U>>where
U: Decoder,
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.
Sourcepub fn poll_flush(&self, cx: &mut Context<'_>, full: bool) -> Poll<Result<()>>
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.
Sourcepub fn poll_shutdown(&self, cx: &mut Context<'_>) -> Poll<Result<()>>
pub fn poll_shutdown(&self, cx: &mut Context<'_>) -> Poll<Result<()>>
Gracefully shuts down the I/O stream.
Sourcepub fn poll_read_pause(&self, cx: &mut Context<'_>) -> Poll<IoStatusUpdate>
pub fn poll_read_pause(&self, cx: &mut Context<'_>) -> Poll<IoStatusUpdate>
Pauses the read task.
Returns status updates.
Sourcepub fn poll_status_update(&self, cx: &mut Context<'_>) -> Poll<IoStatusUpdate>
pub fn poll_status_update(&self, cx: &mut Context<'_>) -> Poll<IoStatusUpdate>
Polls for available status updates.
Sourcepub fn poll_dispatch(&self, cx: &mut Context<'_>)
pub fn poll_dispatch(&self, cx: &mut Context<'_>)
Registers a dispatch task.
Methods from Deref<Target = IoRef>§
Gets the shared configuration.
Sourcepub fn is_wr_backpressure(&self) -> bool
pub fn is_wr_backpressure(&self) -> bool
Checks whether write back-pressure is enabled.
Sourcepub fn close(&self)
pub fn close(&self)
Gracefully closes the connection.
Initiates the I/O stream shutdown process.
Sourcepub fn terminate(&self)
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.
Sourcepub fn encode<U>(
&self,
item: U::Item,
codec: &U,
) -> Result<(), <U as Encoder>::Error>where
U: Encoder,
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.
Sourcepub fn encode_slice(&self, src: &[u8]) -> Result<()>
pub fn encode_slice(&self, src: &[u8]) -> Result<()>
Encodes the slice into the write buffer.
Sourcepub fn encode_bytes<B>(&self, src: B) -> Result<()>
pub fn encode_bytes<B>(&self, src: B) -> Result<()>
Writes bytes to the write buffer.
Sourcepub fn decode<U>(
&self,
codec: &U,
) -> Result<Option<<U as Decoder>::Item>, <U as Decoder>::Error>where
U: Decoder,
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.
Sourcepub fn decode_item<U>(
&self,
codec: &U,
) -> Result<Decoded<<U as Decoder>::Item>, <U as Decoder>::Error>where
U: Decoder,
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.
Sourcepub fn send_buf(&self) -> Result<()>
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.
Sourcepub fn with_read_buf<F, R>(&self, f: F) -> R
pub fn with_read_buf<F, R>(&self, f: F) -> R
Get mut access to read buffer
Sourcepub fn with_write_buf<F, R>(&self, f: F) -> Result<R>
pub fn with_write_buf<F, R>(&self, f: F) -> Result<R>
Get mut access to source write buffer
Sourcepub fn resize_read_buf(&self, buf: &mut BytesMut)
pub fn resize_read_buf(&self, buf: &mut BytesMut)
Make sure buffer has enough free space
Sourcepub fn notify_dispatcher(&self)
pub fn notify_dispatcher(&self)
Wakeup dispatcher
Sourcepub fn notify_timeout(&self)
pub fn notify_timeout(&self)
Wakeup dispatcher and send keep-alive error
Sourcepub fn timer_handle(&self) -> TimerHandle
pub fn timer_handle(&self) -> TimerHandle
Current timer handle
Sourcepub fn start_timer(&self, timeout: Seconds) -> TimerHandle
pub fn start_timer(&self, timeout: Seconds) -> TimerHandle
Start timer
Sourcepub fn stop_timer(&self)
pub fn stop_timer(&self)
Stop timer
Sourcepub fn on_disconnect(&self) -> OnDisconnect ⓘ
pub fn on_disconnect(&self) -> OnDisconnect ⓘ
Notify when io stream get disconnected