Struct Interest

pub struct Interest(/* private field */);

Readiness event interest.

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

Implementations

impl Interest

const READABLE: Interest = _;

Interest in all readable events.

Readable interest includes read-closed events.

const WRITABLE: Interest = _;

Interest in all writable events.

Writable interest includes write-closed events.

const ERROR: Interest = _;

Interest in error events.

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

const PRIORITY: Interest = _;

Returns a Interest set representing priority completion interests.

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());
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());
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());
const fn is_priority(self) -> bool

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());
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());
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

impl BitOr for Interest

type Output = Interest;
fn bitor(self, other: Self) -> Self

impl BitOrAssign for Interest

fn bitor_assign(&mut self, other: Self)

impl Clone for Interest

fn clone(&self) -> Interest

impl Copy for Interest

impl Debug for Interest

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

impl Eq for Interest

impl PartialEq for Interest

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

impl StructuralPartialEq for Interest

Auto Trait Implementations

impl Freeze for Interest

impl RefUnwindSafe for Interest

impl Send for Interest

impl Sync for Interest

impl Unpin for Interest

impl UnsafeUnpin for Interest

impl UnwindSafe for Interest

Blanket Implementations

impl<T> Any for Interest where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Interest where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Interest where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Interest where T: Clone,

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

impl<T> From<T> for Interest

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Interest where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Interest where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Interest where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Interest where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>