tokio::io

Struct Interest

Source
pub struct Interest(/* private fields */);
Available on crate feature net only.
Expand description

Readiness event interest.

Specifies the readiness events the caller is interested in when awaiting on I/O resource readiness states.

Implementations§

Source§

impl Interest

Source

pub const AIO: Interest = _

Available on FreeBSD only.

Interest for POSIX AIO.

Source

pub const LIO: Interest = _

Available on FreeBSD only.

Interest for POSIX AIO lio_listio events.

Source

pub const READABLE: Interest = _

Interest in all readable events.

Readable interest includes read-closed events.

Source

pub const WRITABLE: Interest = _

Interest in all writable events.

Writable interest includes write-closed events.

Source

pub const ERROR: Interest = _

Interest in error events.

Passes error interest to the underlying OS selector. Behavior is platform-specific, read your platform’s documentation.

Source

pub const PRIORITY: Interest = _

Available on Linux or Android only.

Returns a Interest set representing priority completion interests.

Source

pub const fn is_readable(self) -> bool

Returns true if the value includes readable interest.

§Examples
use tokio::io::Interest;

assert!(Interest::READABLE.is_readable());
assert!(!Interest::WRITABLE.is_readable());

let both = Interest::READABLE | Interest::WRITABLE;
assert!(both.is_readable());
Source

pub const fn is_writable(self) -> bool

Returns true if the value includes writable interest.

§Examples
use tokio::io::Interest;

assert!(!Interest::READABLE.is_writable());
assert!(Interest::WRITABLE.is_writable());

let both = Interest::READABLE | Interest::WRITABLE;
assert!(both.is_writable());
Source

pub const fn is_error(self) -> bool

Returns true if the value includes error interest.

§Examples
use tokio::io::Interest;

assert!(Interest::ERROR.is_error());
assert!(!Interest::WRITABLE.is_error());

let combined = Interest::READABLE | Interest::ERROR;
assert!(combined.is_error());
Source

pub const fn is_priority(self) -> bool

Available on Linux or Android only.

Returns true if the value includes priority interest.

§Examples
use tokio::io::Interest;

assert!(!Interest::READABLE.is_priority());
assert!(Interest::PRIORITY.is_priority());

let both = Interest::READABLE | Interest::PRIORITY;
assert!(both.is_priority());
Source

pub const fn add(self, other: Interest) -> Interest

Add together two Interest values.

This function works from a const context.

§Examples
use tokio::io::Interest;

const BOTH: Interest = Interest::READABLE.add(Interest::WRITABLE);

assert!(BOTH.is_readable());
assert!(BOTH.is_writable());
Source

pub fn remove(self, other: Interest) -> Option<Interest>

Remove Interest from self.

Interests present in other but not in self are ignored.

Returns None if the set would be empty after removing Interest.

§Examples
use tokio::io::Interest;

const RW_INTEREST: Interest = Interest::READABLE.add(Interest::WRITABLE);

let w_interest = RW_INTEREST.remove(Interest::READABLE).unwrap();
assert!(!w_interest.is_readable());
assert!(w_interest.is_writable());

// Removing all interests from the set returns `None`.
assert_eq!(w_interest.remove(Interest::WRITABLE), None);

// Remove all interests at once.
assert_eq!(RW_INTEREST.remove(RW_INTEREST), None);

Trait Implementations§

Source§

impl BitOr for Interest

Source§

type Output = Interest

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign for Interest

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl Clone for Interest

Source§

fn clone(&self) -> Interest

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Interest

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Interest

Source§

fn eq(&self, other: &Interest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Interest

Source§

impl Eq for Interest

Source§

impl StructuralPartialEq for Interest

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes