Identifier

Trait Identifier 

Source
pub unsafe trait Identifier {
    type Token: Token;

    // Required method
    fn token(&self) -> Self::Token;

    // Provided method
    fn owns_token(&self, token: &Self::Token) -> bool { ... }
}
Expand description

An Identifier is a process unique identifier

you are guaranteed that two instances of this identifier will never compare equal You can also get a token that this identifier recognizes, which you can use to mark other types as logically owned by the identifier. No other identifier will recognize tokens made be a different identifier while both identifiers are live.

§Safety

  • ident.owns(&token) must return true for any token returned from ident.token() regardless of when the token was created.
  • If two tokens compare equal, then Identifier::owns must act the same for both of them
    • i.e. it must return false for both tokens, or it must return true for both tokens
  • Two instances of Identifier must never return true for the same token if either the two identifier or the tokens they generate can both exist on the same thread.

Required Associated Types§

Source

type Token: Token

The tokens that this Identifier generates

Required Methods§

Source

fn token(&self) -> Self::Token

Create a new token

Provided Methods§

Source

fn owns_token(&self, token: &Self::Token) -> bool

Check if this token was created by this identifier

Implementations on Foreign Types§

Source§

impl<I: ?Sized + Identifier> Identifier for &mut I

Source§

type Token = <I as Identifier>::Token

Source§

fn owns_token(&self, token: &Self::Token) -> bool

Source§

fn token(&self) -> Self::Token

Source§

impl<I: ?Sized + Identifier> Identifier for Box<I>

Available on crate feature alloc only.
Source§

type Token = <I as Identifier>::Token

Source§

fn owns_token(&self, token: &Self::Token) -> bool

Source§

fn token(&self) -> Self::Token

Implementors§