pub struct Events { /* private fields */ }
Expand description
A container for I/O events.
Implementations§
source§impl Events
impl Events
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new container for events, using the default capacity.
The default capacity is 1024.
§Examples
use polling::Events;
let events = Events::new();
sourcepub fn with_capacity(capacity: NonZeroUsize) -> Self
pub fn with_capacity(capacity: NonZeroUsize) -> Self
Create a new container with the provided capacity.
§Examples
use polling::Events;
use std::num::NonZeroUsize;
let capacity = NonZeroUsize::new(1024).unwrap();
let events = Events::with_capacity(capacity);
sourcepub fn iter(&self) -> impl Iterator<Item = Event> + '_
pub fn iter(&self) -> impl Iterator<Item = Event> + '_
Create a new iterator over I/O events.
This returns all of the events in the container, excluding the notification event.
§Examples
use polling::{Event, Events, Poller};
use std::time::Duration;
let poller = Poller::new()?;
let mut events = Events::new();
poller.wait(&mut events, Some(Duration::from_secs(0)))?;
assert!(events.iter().next().is_none());
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Delete all of the events in the container.
§Examples
use polling::{Event, Events, Poller};
let poller = Poller::new()?;
let mut events = Events::new();
/* register some sources */
poller.wait(&mut events, None)?;
events.clear();
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of events in the container.
§Examples
use polling::Events;
let events = Events::new();
assert_eq!(events.len(), 0);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the container contains no events.
§Examples
use polling::Events;
let events = Events::new();
assert!(events.is_empty());
sourcepub fn capacity(&self) -> NonZeroUsize
pub fn capacity(&self) -> NonZeroUsize
Get the total capacity of the list.
§Examples
use polling::Events;
use std::num::NonZeroUsize;
let cap = NonZeroUsize::new(10).unwrap();
let events = Events::with_capacity(std::num::NonZeroUsize::new(10).unwrap());
assert_eq!(events.capacity(), cap);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Events
impl !RefUnwindSafe for Events
impl Send for Events
impl !Sync for Events
impl Unpin for Events
impl UnwindSafe for Events
Blanket Implementations§
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. Read more