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 anytokenreturned fromident.token()regardless of when the token was created.- If two tokens compare equal, then
Identifier::ownsmust 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
Identifiermust 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§
Required Methods§
Provided Methods§
Sourcefn owns_token(&self, token: &Self::Token) -> bool
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
impl<I: ?Sized + Identifier> Identifier for &mut I
Source§impl<I: ?Sized + Identifier> Identifier for Box<I>
Available on crate feature alloc only.
impl<I: ?Sized + Identifier> Identifier for Box<I>
Available on crate feature
alloc only.