Skip to main content

WriteHalf

Struct WriteHalf 

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

The writing end of one side. Dropping it without WriteHalf::finish resets the direction, as a dropped socket would.

Implementations§

Source§

impl WriteHalf

Source

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

Wait for the peer’s confirmed node death, even while no bytes are being produced. Ordinary FIN and endpoint release are not death.

Shares the writer’s readiness registration: poll this from the same task as writes, not from a second concurrent writer task.

Source

pub fn id(&self) -> StreamId

Source

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

Write what fits now; Error::WouldBlock when the ring is full.

Source

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

Write the complete buffer atomically. When it does not all fit, returns Error::WouldBlock without publishing a prefix.

Source

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

Park until something fits, then write it. Blocks the thread.

Source

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

Write everything, waiting as needed. A failure part-way has already committed a prefix; nothing is replayed.

Source

pub fn finish(&mut self) -> Result<()>

No more bytes from this side (FIN); what is buffered still reaches the reader, then it sees a clean end. The other direction is unaffected. AsyncWriteExt::shutdown does the same.

Source

pub fn reset(&mut self)

Abandon the direction: the reader gets an error and buffered bytes are discarded.

Source

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

The same wait, bounded: false is the timeout and nothing else, which is how a caller with a deadline of its own gives up without giving up its stream.

Source

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

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

Source

pub fn wait_writable_exact(&self, needed: usize) -> Result<()>

Park until an atomic write of needed bytes can be attempted.

Source

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

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

Source

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

Task readiness for an indivisible write of needed bytes.

Trait Implementations§

Source§

impl Drop for WriteHalf

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.