/// Describes the readiness state of an I/O resources. /// /// `Ready` tracks which operation an I/O resource is ready to perform. #[cfg_attr(docsrs, doc(cfg(feature = "net")))] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pubstruct Ready(usize);
/// Returns a `Ready` representing readiness for all operations. #[cfg(any(target_os = "linux", target_os = "android"))] pubconst ALL: Ready =
Ready(READABLE | WRITABLE | READ_CLOSED | WRITE_CLOSED | ERROR | PRIORITY);
/// Returns a `Ready` representing readiness for all operations. #[cfg(not(any(target_os = "linux", target_os = "android")))] pubconst ALL: Ready = Ready(READABLE | WRITABLE | READ_CLOSED | WRITE_CLOSED | ERROR);
// Must remain crate-private to avoid adding a public dependency on Mio. pub(crate) fn from_mio(event: &mio::event::Event) -> Ready { letmut ready = Ready::EMPTY;
/// Returns true if `Ready` is the empty set. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(Ready::EMPTY.is_empty()); /// assert!(!Ready::READABLE.is_empty()); /// ``` pubfn is_empty(self) -> bool { self == Ready::EMPTY
}
/// Returns `true` if the value includes `readable`. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(!Ready::EMPTY.is_readable()); /// assert!(Ready::READABLE.is_readable()); /// assert!(Ready::READ_CLOSED.is_readable()); /// assert!(!Ready::WRITABLE.is_readable()); /// ``` pubfn is_readable(self) -> bool { self.contains(Ready::READABLE) || self.is_read_closed()
}
/// Returns `true` if the value includes writable `readiness`. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(!Ready::EMPTY.is_writable()); /// assert!(!Ready::READABLE.is_writable()); /// assert!(Ready::WRITABLE.is_writable()); /// assert!(Ready::WRITE_CLOSED.is_writable()); /// ``` pubfn is_writable(self) -> bool { self.contains(Ready::WRITABLE) || self.is_write_closed()
}
/// Returns `true` if the value includes read-closed `readiness`. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(!Ready::EMPTY.is_read_closed()); /// assert!(!Ready::READABLE.is_read_closed()); /// assert!(Ready::READ_CLOSED.is_read_closed()); /// ``` pubfn is_read_closed(self) -> bool { self.contains(Ready::READ_CLOSED)
}
/// Returns `true` if the value includes write-closed `readiness`. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(!Ready::EMPTY.is_write_closed()); /// assert!(!Ready::WRITABLE.is_write_closed()); /// assert!(Ready::WRITE_CLOSED.is_write_closed()); /// ``` pubfn is_write_closed(self) -> bool { self.contains(Ready::WRITE_CLOSED)
}
/// Returns `true` if the value includes priority `readiness`. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(!Ready::EMPTY.is_priority()); /// assert!(!Ready::WRITABLE.is_priority()); /// assert!(Ready::PRIORITY.is_priority()); /// ``` #[cfg(any(target_os = "linux", target_os = "android"))] #[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))] pubfn is_priority(self) -> bool { self.contains(Ready::PRIORITY)
}
/// Returns `true` if the value includes error `readiness`. /// /// # Examples /// /// ``` /// use tokio::io::Ready; /// /// assert!(!Ready::EMPTY.is_error()); /// assert!(!Ready::WRITABLE.is_error()); /// assert!(Ready::ERROR.is_error()); /// ``` pubfn is_error(self) -> bool { self.contains(Ready::ERROR)
}
/// Returns true if `self` is a superset of `other`. /// /// `other` may represent more than one readiness operations, in which case /// the function only returns true if `self` contains all readiness /// specified in `other`. pub(crate) fn contains<T: Into<Self>>(self, other: T) -> bool { let other = other.into();
(self & other) == other
}
/// Creates a `Ready` instance using the given `usize` representation. /// /// The `usize` representation must have been obtained from a call to /// `Readiness::as_usize`. /// /// This function is mainly provided to allow the caller to get a /// readiness value from an `AtomicUsize`. pub(crate) fn from_usize(val: usize) -> Ready {
Ready(val & Ready::ALL.as_usize())
}
/// Returns a `usize` representation of the `Ready` value. /// /// This function is mainly provided to allow the caller to store a /// readiness value in an `AtomicUsize`. pub(crate) fn as_usize(self) -> usize { self.0
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.