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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.