mio::event

Struct Events

Source
pub struct Events { /* private fields */ }
Expand description

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.

§Examples

use mio::{Events, Poll};
use std::time::Duration;

let mut events = Events::with_capacity(1024);
let mut poll = Poll::new()?;

// Register `event::Source`s with `poll`.

poll.poll(&mut events, Some(Duration::from_millis(100)))?;

for event in events.iter() {
    println!("Got an event for {:?}", event.token());
}

Implementations§

Source§

impl Events

Source

pub fn with_capacity(capacity: usize) -> Events

Return a new Events capable of holding up to capacity events.

§Examples
use mio::Events;

let events = Events::with_capacity(1024);
assert_eq!(1024, events.capacity());
Source

pub fn capacity(&self) -> usize

Returns the number of Event values that self can hold.

use mio::Events;

let events = Events::with_capacity(1024);
assert_eq!(1024, events.capacity());
Source

pub fn is_empty(&self) -> bool

Returns true if self contains no Event values.

§Examples
use mio::Events;

let events = Events::with_capacity(1024);
assert!(events.is_empty());
Source

pub fn iter(&self) -> Iter<'_>

Returns an iterator over the Event values.

§Examples
use mio::{Events, Poll};
use std::time::Duration;

let mut events = Events::with_capacity(1024);
let mut poll = Poll::new()?;

// Register handles with `poll`.

poll.poll(&mut events, Some(Duration::from_millis(100)))?;

for event in events.iter() {
    println!("Got an event for {:?}", event.token());
}
Source

pub fn clear(&mut self)

Clearing all Event values from container explicitly.

§Notes

Events are cleared before every poll, so it is not required to call this manually.

§Examples
use mio::{Events, Poll};
use std::time::Duration;

let mut events = Events::with_capacity(1024);
let mut poll = Poll::new()?;

// Register handles with `poll`.

poll.poll(&mut events, Some(Duration::from_millis(100)))?;

// Clear all events.
events.clear();
assert!(events.is_empty());

Trait Implementations§

Source§

impl Debug for Events

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> IntoIterator for &'a Events

Source§

type Item = &'a Event

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes