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§
Sourcefn 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
.
Sourcefn 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
.
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.