Skip to main content

IoHandle

Struct IoHandle 

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

Copy handle for IO operations from async tasks.

Provides source registration with the mio reactor. Obtained from IoHandle::current.

§Safety

The raw pointers are valid for the lifetime of the crate::Runtime. Single-threaded — no concurrent access.

Implementations§

Source§

impl IoHandle

Source

pub fn current() -> IoHandle

Returns the IoHandle for the currently running runtime.

Use when you need to register a mio source from inside an async task — e.g., when constructing a TcpStream or UdpSocket. Mirrors tokio::runtime::Handle::current().

§Panics

Panics if called outside a Runtime::block_on context.

Source

pub fn register( &self, source: &mut impl Source, interest: Interest, waker: Waker, ) -> Result<Token>

Register a mio source with the given interest and waker.

Returns the assigned token for use with deregister.

Source

pub fn set_waker(&self, token: Token, waker: Waker)

Update the waker for a token. Called when a stream is polled from a different task than the one that registered it (e.g., after into_split).

Source

pub fn readiness(&self, token: Token) -> Readiness

Query the readiness state for a token.

Returns the last-known readiness from epoll events. Cleared after the task consumes the readiness (calls clear_readable/clear_writable).

Source

pub fn clear_readable(&self, token: Token)

Clear the readable flag for a token. Call after a successful read or WouldBlock to wait for the next epoll notification.

Source

pub fn clear_writable(&self, token: Token)

Clear the writable flag for a token.

Source

pub unsafe fn deregister( &self, source: &mut impl Source, token: Token, ) -> Result<()>

Deregister a source and release its token.

§Safety

The driver and registry pointers must be valid (Runtime lifetime).

Trait Implementations§

Source§

impl Clone for IoHandle

Source§

fn clone(&self) -> IoHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for IoHandle

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.