pub struct Events { /* fields omitted */ }
A collection of readiness events.
Events
is passed as an argument to Poll::poll
and will be used to
receive any new readiness events received since the last poll. Usually, a
single Events
instance is created at the same time as a Poll
and
reused on each call to Poll::poll
.
See Poll
for more documentation on polling.
use mio::{Events, Poll};
use std::time::Duration;
let mut events = Events::with_capacity(1024);
let poll = Poll::new()?;
assert_eq!(0, events.len());
poll.poll(&mut events, Some(Duration::from_millis(100)))?;
for event in &events {
println!("event={:?}", event);
}
Return a new Events
capable of holding up to capacity
events.
use mio::Events;
let events = Events::with_capacity(1024);
assert_eq!(1024, events.capacity());
Returns the number of Event
values that self
can hold.
use mio::Events;
let events = Events::with_capacity(1024);
assert_eq!(1024, events.capacity());
Returns true
if self
contains no Event
values.
use mio::Events;
let events = Events::with_capacity(1024);
assert!(events.is_empty());
Returns an iterator over the Event
values.
use mio::{Events, Poll};
use std::time::Duration;
let mut events = Events::with_capacity(1024);
let poll = Poll::new()?;
poll.poll(&mut events, Some(Duration::from_millis(100)))?;
for event in events.iter() {
println!("event={:?}", event);
}
Clearing all Event
values from container explicitly.
use mio::{Events, Poll};
use std::time::Duration;
let mut events = Events::with_capacity(1024);
let poll = Poll::new()?;
for _ in 0..2 {
events.clear();
poll.poll(&mut events, Some(Duration::from_millis(100)))?;
for event in events.iter() {
println!("event={:?}", event);
}
}
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Formats the value using the given formatter. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static