Struct Event
struct Event { ... }
A readiness event.
Event is a readiness state paired with a Token. It is returned by
Poll::poll.
For more documentation on polling and events, see Poll.
Implementations
impl Event
fn token(self: &Self) -> TokenReturns the event's token.
fn is_readable(self: &Self) -> boolReturns true if the event contains readable readiness.
Notes
Out-of-band (OOB) data also triggers readable events. But most applications don't actually read OOB data, this could leave an application open to a Denial-of-Service (Dos) attack, see https://github.com/sandstorm-io/sandstorm-website/blob/58f93346028c0576e8147627667328eaaf4be9fa/_posts/2015-04-08-osx-security-bug.md. However because Mio uses edge-triggers it will not result in an infinite loop as described in the article above.
fn is_writable(self: &Self) -> boolReturns true if the event contains writable readiness.
fn is_error(self: &Self) -> boolReturns true if the event contains error readiness.
Error events occur when the socket enters an error state. In this case, the socket will also receive a readable or writable event. Reading or writing to the socket will result in an error.
Notes
Method is available on all platforms, but not all platforms trigger the error event.
The table below shows what flags are checked on what OS.
OS selector Flag(s) checked epoll EPOLLERRkqueue EV_ERRORandEV_EOFwithfflagsset to0.fn is_read_closed(self: &Self) -> boolReturns true if the event contains read closed readiness.
Notes
Read closed readiness can be expected after any of the following have occurred:
- The local stream has shutdown the read half of its socket
- The local stream has shutdown both the read half and the write half of its socket
- The peer stream has shutdown the write half its socket; this sends a
FINpacket that has been received by the local stream
Method is a best effort implementation. While some platforms may not return readiness when read half is closed, it is guaranteed that false-positives will not occur.
The table below shows what flags are checked on what OS.
OS selector Flag(s) checked epoll EPOLLHUP, orEPOLLINandEPOLLRDHUPkqueue EV_EOFfn is_write_closed(self: &Self) -> boolReturns true if the event contains write closed readiness.
Notes
On epoll this is essentially a check for
EPOLLHUPflag as the local stream shutting down its write half does not trigger this event.On kqueue the local stream shutting down the write half of its socket will trigger this event.
Method is a best effort implementation. While some platforms may not return readiness when write half is closed, it is guaranteed that false-positives will not occur.
The table below shows what flags are checked on what OS.
OS selector Flag(s) checked epoll EPOLLHUP, oronly EPOLLERR, orEPOLLOUTandEPOLLERRkqueue EV_EOFfn is_priority(self: &Self) -> boolReturns true if the event contains priority readiness.
Notes
Method is available on all platforms, but not all platforms trigger the priority event.
The table below shows what flags are checked on what OS.
OS selector Flag(s) checked epoll EPOLLPRIkqueue Not supported fn is_aio(self: &Self) -> boolReturns true if the event contains AIO readiness.
Notes
Method is available on all platforms, but not all platforms support AIO.
The table below shows what flags are checked on what OS.
OS selector Flag(s) checked epoll Not supported kqueue1 EVFILT_AIO1: Only supported on DragonFly BSD, FreeBSD, iOS and macOS.
fn is_lio(self: &Self) -> boolReturns true if the event contains LIO readiness.
Notes
Method is available on all platforms, but only FreeBSD supports LIO. On FreeBSD this method checks the
EVFILT_LIOflag.
impl Clone for Event
fn clone(self: &Self) -> Event
impl Debug for Event
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
impl<T> Any for Event
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Event
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Event
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Event
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Event
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Event
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Event
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Event
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Event
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>