跳到主要内容

Interest

搜索

结构体 Interest 

Source
pub struct Interest(/* private fields */);
展开描述

就绪事件关注项(interest)。

指定在等待 I/O 资源就绪状态时调用方感兴趣的就绪事件。

实现§

Source§

impl Interest

Source

pub const READABLE: Interest

对所有可读事件感兴趣。

可读兴趣包含读关闭事件。

Source

pub const WRITABLE: Interest

对所有可写事件感兴趣。

可写兴趣包含写关闭事件。

Source

pub const ERROR: Interest

对错误事件感兴趣。

将错误兴趣传递给底层 OS 选择器。 行为因平台而异,请阅读你所使用平台的文档。

Source

pub const fn is_readable(self) -> bool

如果该值包含可读兴趣,则返回 true。

§示例
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

如果该值包含可写兴趣,则返回 true。

§示例
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

如果该值包含错误兴趣,则返回 true。

§示例
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 add(self, other: Interest) -> Interest

将两个 Interest 值相加。

此函数可以在 const 上下文中使用。

§示例
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>

self 中移除 Interest

仅移除 self 中存在的那些 Interest; 存在于 other存在于 self 中的兴趣将被忽略。

如果在移除 Interest 后集合为空,则返回 None

§示例
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 实现§

Source§

impl BitOr for Interest

Source§

type Output = Interest

应用 | 运算符后得到的类型。
Source§

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

Performs the | operation. 更多信息
Source§

impl BitOrAssign for Interest

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. 更多信息
Source§

impl Clone for Interest

Source§

fn clone(&self) -> Interest

返回值的副本。 更多信息
1.0.0 · Source§

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

Performs copy-assignment from source. 更多信息
Source§

impl Debug for Interest

Source§

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

使用给定的格式化器格式化此值。 更多信息
Source§

impl PartialEq for Interest

Source§

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

测试 selfother 值是否相等,供 == 运算符使用。
1.0.0 · Source§

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

测试 != 运算符。默认实现几乎总是够用,除非有非常充分的理由,否则不应被覆盖。
Source§

impl Copy for Interest

Source§

impl Eq for Interest

Source§

impl StructuralPartialEq for Interest

自动 Trait 实现§

Blanket 实现§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
Source§

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

Source§

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

Mutably borrows from an owned value. 更多信息
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. 更多信息
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回传入的参数。

Source§

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

Source§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换的具体行为取决于 From<T> for U 的实现方式。

Source§

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

Source§

type Owned = T

获得所有权后的类型。
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
Source§

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

Uses borrowed data to replace owned data, usually by cloning. 更多信息
Source§

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

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

转换出错时返回的类型。
Source§

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

执行转换。