[][src]Struct mio::Events

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.

Examples

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

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

assert_eq!(0, events.len());

// Register `Evented` handles with `poll`

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

for event in &events {
    println!("event={:?}", event);
}

Methods

impl Events[src]

pub fn with_capacity(capacity: usize) -> Events[src]

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());

pub fn capacity(&self) -> usize[src]

Returns the number of Event values that self can hold.

use mio::Events;

let events = Events::with_capacity(1024);

assert_eq!(1024, events.capacity());

pub fn is_empty(&self) -> bool[src]

Returns true if self contains no Event values.

Examples

use mio::Events;

let events = Events::with_capacity(1024);

assert!(events.is_empty());

Important traits for Iter<'a>
pub fn iter(&self) -> Iter[src]

Returns an iterator over the Event values.

Examples

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

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

// Register handles with `poll`

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

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

pub fn clear(&mut self)[src]

Clearing all Event values from container explicitly.

Examples

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

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

// Register handles with `poll`
for _ in 0..2 {
    events.clear();
    poll.poll(&mut events, Some(Duration::from_millis(100)))?;

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

Trait Implementations

impl<'a> IntoIterator for &'a Events[src]

type Item = Event

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

impl IntoIterator for Events[src]

type Item = Event

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

impl Debug for Events[src]

Auto Trait Implementations

impl Send for Events

impl Unpin for Events

impl Sync for Events

impl UnwindSafe for Events

impl RefUnwindSafe for Events

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]