Trait token_cell::core::TokenTrait
source · pub trait TokenTrait: Sized {
type ConstructionError;
type RunError;
type Identifier;
type ComparisonError;
// Required methods
fn new() -> Result<Self, Self::ConstructionError>;
fn with_token<R, F: FnOnce(Self) -> R>(f: F) -> Result<R, Self::RunError>;
fn identifier(&self) -> Self::Identifier;
fn compare(
&self,
id: &Self::Identifier
) -> Result<(), Self::ComparisonError>;
}
Expand description
A trait for tokens
Required Associated Types§
Required Methods§
sourcefn new() -> Result<Self, Self::ConstructionError>
fn new() -> Result<Self, Self::ConstructionError>
Constructs a new Token.
sourcefn with_token<R, F: FnOnce(Self) -> R>(f: F) -> Result<R, Self::RunError>
fn with_token<R, F: FnOnce(Self) -> R>(f: F) -> Result<R, Self::RunError>
Constructs a new Token, and provides it to the closure.
While this should allow to provide a traitified version of ghost-cell
, it seems the compiler only detects
the lifetime invariance with inherent methods.
sourcefn identifier(&self) -> Self::Identifier
fn identifier(&self) -> Self::Identifier
Returns the Token’s identifier, which cells may store to allow comparison.
sourcefn compare(&self, id: &Self::Identifier) -> Result<(), Self::ComparisonError>
fn compare(&self, id: &Self::Identifier) -> Result<(), Self::ComparisonError>
Allows the cell to compare its identifier to the Token.