Skip to main content

ReadHalf

Struct ReadHalf 

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

The reading end of one side. Dropping it tells the peer’s writer that nothing more will be read.

Implementations§

Source§

impl ReadHalf

Source

pub fn id(&self) -> StreamId

Source

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

Read what is there now. Ok(0) is clean end of stream; Error::WouldBlock means nothing yet.

Source

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

Read the complete buffer atomically. When it is not all available, returns Error::WouldBlock without consuming a prefix.

Source

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

Park until something can be read, then read it. Ok(0) is clean end of stream. Blocks the thread; an async runtime uses AsyncRead.

Source

pub fn blocking_read_chunk(&self, max: usize) -> Result<Bytes>

Up to max bytes as one owned chunk; empty at clean end of stream.

Source

pub fn wait_readable_timeout(&self, timeout: Duration) -> Result<bool>

The same wait, bounded: false is the timeout and nothing else.

Source

pub fn wait_readable(&self) -> Result<()>

Park until a read would make progress or the direction ended.

Source

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

Readiness for a task: Ready when a read would make progress or the direction ended, otherwise the waker is registered and Pending comes back. Runtime-neutral; the tokio feature builds AsyncRead on it.

Trait Implementations§

Source§

impl Drop for ReadHalf

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.