pub struct Interest(/* 私有字段 */);展开描述
就绪事件兴趣。
指定调用者在等待 I/O 资源就绪状态时所感兴趣的就绪事件。
实现§
源代码§impl Interest
impl Interest
源代码pub const fn is_readable(self) -> bool
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
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
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
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>
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 BitOrAssign for Interest
impl BitOrAssign for Interest
源代码§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Performs the
|= operation. 更多信息impl Copy for Interest
impl Eq for Interest
impl StructuralPartialEq for Interest
自动 trait 实现§
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 实现§
源代码§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
源代码§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. 更多信息