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§

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 WaitContext.

Implementations on Foreign Types§

source§

impl EventToken for u8

source§

fn as_raw_token(&self) -> u64

source§

fn from_raw_token(data: u64) -> Self

source§

impl EventToken for u64

source§

fn as_raw_token(&self) -> u64

source§

fn from_raw_token(data: u64) -> Self

source§

impl EventToken for usize

source§

fn as_raw_token(&self) -> u64

source§

fn from_raw_token(data: u64) -> Self

source§

impl EventToken for ()

source§

fn as_raw_token(&self) -> u64

source§

fn from_raw_token(_data: u64) -> Self

source§

impl EventToken for u32

source§

fn as_raw_token(&self) -> u64

source§

fn from_raw_token(data: u64) -> Self

source§

impl EventToken for u16

source§

fn as_raw_token(&self) -> u64

source§

fn from_raw_token(data: u64) -> Self

Implementors§

source§

impl EventToken for Descriptor

Implement token for implementations that wish to use this struct as such