Trait vmm_sys_util::poll::PollToken [−][src]
pub trait PollToken {
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
fn as_raw_token(&self) -> u64
fn as_raw_token(&self) -> u64
Converts this token into a u64 that can be turned back into a token via from_raw_token
.
fn from_raw_token(data: u64) -> Self
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
.