Trait base::EventToken
source · pub trait EventToken {
// Required methods
fn as_raw_token(&self) -> u64;
fn from_raw_token(data: u64) -> Self;
}
Expand description
Trait that can be used to associate events with arbitrary enums when using
WaitContext
.
Simple enums that have no or primitive variant data data can use the #[derive(EventToken)]
custom derive to implement this trait. See
event_token_derive::event_token for details.
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 WaitContext
.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl EventToken for u8
impl EventToken for u8
fn as_raw_token(&self) -> u64
fn from_raw_token(data: u64) -> Self
source§impl EventToken for u16
impl EventToken for u16
fn as_raw_token(&self) -> u64
fn from_raw_token(data: u64) -> Self
source§impl EventToken for u32
impl EventToken for u32
fn as_raw_token(&self) -> u64
fn from_raw_token(data: u64) -> Self
source§impl EventToken for u64
impl EventToken for u64
fn as_raw_token(&self) -> u64
fn from_raw_token(data: u64) -> Self
source§impl EventToken for ()
impl EventToken for ()
fn as_raw_token(&self) -> u64
fn from_raw_token(_data: u64) -> Self
source§impl EventToken for usize
impl EventToken for usize
fn as_raw_token(&self) -> u64
fn from_raw_token(data: u64) -> Self
Implementors§
impl EventToken for Descriptor
Implement token for implementations that wish to use this struct as such