pub struct Interest(/* private fields */);展开描述
就绪事件关注项(interest)。
指定在等待 I/O 资源就绪状态时调用方感兴趣的就绪事件。
实现§
Source§impl Interest
impl Interest
Sourcepub 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());Sourcepub 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());Sourcepub 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());Sourcepub 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());Sourcepub fn remove(self, other: Interest) -> Option<Interest>
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 BitOrAssign for Interest
impl BitOrAssign for Interest
Source§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 实现§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. 更多信息