vmm_sys_util::poll

Trait PollToken

Source
pub trait PollToken {
    // Required methods
    fn as_raw_token(&self) -> u64;
    fn from_raw_token(data: u64) -> Self;
}
Expand description

Trait for a token that can be associated with an fd in a PollContext.

Simple enums that have no or primitive variant data can use the #[derive(PollToken)] custom derive to implement this trait.

Required Methods§

Source

fn as_raw_token(&self) -> u64

Converts this token into a u64 that can be turned back into a token via from_raw_token.

Source

fn from_raw_token(data: u64) -> Self

Converts a raw token as returned from as_raw_token back into a token.

It is invalid to give a raw token that was not returned via as_raw_token from the same Self. The implementation can expect that this will never happen as a result of its usage in PollContext.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl PollToken for u8

Source§

fn as_raw_token(&self) -> u64

Source§

fn from_raw_token(data: u64) -> Self

Source§

impl PollToken for u16

Source§

fn as_raw_token(&self) -> u64

Source§

fn from_raw_token(data: u64) -> Self

Source§

impl PollToken for u32

Source§

fn as_raw_token(&self) -> u64

Source§

fn from_raw_token(data: u64) -> Self

Source§

impl PollToken for u64

Source§

fn as_raw_token(&self) -> u64

Source§

fn from_raw_token(data: u64) -> Self

Source§

impl PollToken for ()

Source§

fn as_raw_token(&self) -> u64

Source§

fn from_raw_token(_data: u64) -> Self

Source§

impl PollToken for usize

Source§

fn as_raw_token(&self) -> u64

Source§

fn from_raw_token(data: u64) -> Self

Implementors§