跳到主要内容

Interest

搜索

结构体 Interest 

源代码
pub struct Interest(/* 私有字段 */);
展开描述

就绪事件兴趣。

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

实现§

源代码§

impl Interest

源代码

pub const READABLE: Interest

对所有可读事件感兴趣。

可读兴趣包括读取关闭事件。

源代码

pub const WRITABLE: Interest

对所有可写事件感兴趣。

可写兴趣包括写入关闭事件。

源代码

pub const ERROR: Interest

对错误事件感兴趣。

将错误兴趣传递给底层 OS 选择器。行为是平台特定的,请阅读你所在平台的文档。

源代码

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());
源代码

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());
源代码

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());
源代码

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());
源代码

pub fn remove(self, other: Interest) -> Option<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 实现§

源代码§

impl BitOr for Interest

源代码§

type Output = Interest

应用 | 运算符后得到的类型。
源代码§

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

Performs the | operation. 更多信息
源代码§

impl BitOrAssign for Interest

源代码§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. 更多信息
源代码§

impl Clone for Interest

源代码§

fn clone(&self) -> Interest

返回值的副本。 更多信息
1.0.0 · 源代码§

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

Performs copy-assignment from source. 更多信息
源代码§

impl Debug for Interest

源代码§

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

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

impl PartialEq for Interest

源代码§

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

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

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

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

impl Copy for Interest

源代码§

impl Eq for Interest

源代码§

impl StructuralPartialEq for Interest

自动 trait 实现§

blanket 实现§

源代码§

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

源代码§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
源代码§

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

源代码§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
源代码§

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

源代码§

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

Mutably borrows from an owned value. 更多信息
源代码§

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

源代码§

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. 更多信息
源代码§

impl<T> From<T> for T

源代码§

fn from(t: T) -> T

原样返回参数。

源代码§

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

源代码§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换是 From<T> for U 实现选择执行的操作。

源代码§

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

源代码§

type Owned = T

获得所有权后的类型。
源代码§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
源代码§

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

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

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

源代码§

type Error = Infallible

转换出错时返回的类型。
源代码§

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

执行转换。
源代码§

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

源代码§

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

转换出错时返回的类型。
源代码§

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

执行转换。