pub trait WritableHandle {
    // Required methods
    fn poll_writable(
        &self,
        cx: &mut Context<'_>
    ) -> Poll<Result<WritableState, Status>>;
    fn need_writable(&self, cx: &mut Context<'_>) -> Result<(), Status>;
}
Expand description

A Handle that receives notifications when it is writable.

Examples

ready!(self.poll_writable(cx))?;
match /* make write syscall */ {
    Err(zx::Status::SHOULD_WAIT) => {
        self.need_writable(cx)?;
        Poll::Pending
    }
    status => Poll::Ready(status),
}

Required Methods§

source

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

If the object is ready for writing, returns Ready with the writable state. If the implementor returns Pending, it should first ensure that need_writable is called.

This should be called in a poll function before making a write syscall. If the syscall returns SHOULD_WAIT, you must call need_writable to schedule wakeup when the object is writable.

The returned WritableState does not necessarily reflect an observed OBJECT_WRITABLE signal. We optimistically assume the object remains writable until need_writable is called. If you only want to write once the object is confirmed to be writable, call need_writable with a no-op waker before the first poll.

source

fn need_writable(&self, cx: &mut Context<'_>) -> Result<(), Status>

Arranges for the current task to be woken when the object receives an OBJECT_WRITABLE or OBJECT_PEER_CLOSED signal.

Implementors§

source§

impl WritableHandle for Socket

source§

impl<T> WritableHandle for RWHandle<T>where T: AsHandleRef,