Struct mio::Events [] [src]

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 call to poll. Usually, a single Events instance is created at the same time as the Poll and the single instance is reused for each call to 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().unwrap();

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

// Register `Evented` handles with `poll`

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

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

Methods

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

Returns the Event at the given index, or None if the index is out of bounds.

Examples

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

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

// Register handles with `poll`

let n = poll.poll(&mut events, Some(Duration::from_millis(100))).unwrap();

for i in 0..n {
    println!("event={:?}", events.get(i).unwrap());
}

Returns the number of Event values currently in self.

Examples

use mio::Events;

let events = Events::with_capacity(1024);

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

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.

Examples

use mio::Events;

let events = Events::with_capacity(1024);

assert!(events.is_empty());

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

// Register handles with `poll`

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

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

Trait Implementations

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl Debug for Events
[src]

Formats the value using the given formatter.