Skip to main content

RuntimeToken

Struct RuntimeToken 

Source
pub struct RuntimeToken(/* private fields */);
Expand description

The default runtime-checked token type.

Because this token type is checked at runtime, it can make sense to have a global token type for your whole application.

And because this runtime token is backed by a u64, it would take you 60 years continuously instantiating them at 10GHz (which is unfeasible with existing hardware) before an overflow may cause multiple tokens to share the same runtime identifier; so you can safely assume that this token type will never let you access a cell that you shouldn’t be accessing.

Trait Implementations§

Source§

impl Debug for RuntimeToken

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TokenTrait for RuntimeToken

Source§

type ComparisonMaySpuriouslyEq = False

Whether or not comparison between two distinct token could yield eq. Read more
Source§

type RunError = Infallible

TokenTrait::with_token may fail, typically if construction failed. Read more
Source§

type Identifier = u64

Lets a TokenCell keep track of the token. Read more
Source§

type ComparisonError = IdMismatch<u64>

core::convert::Infallible unless TokenTrait::compare is fallible (ie. comparison is done at runtime).
Source§

type Branded<'a> = RuntimeToken

Rebrands the token, this is necessary for GhostToken to function properly
Source§

fn with_token<R, F: for<'a> FnOnce(Self::Branded<'a>) -> R>( f: F, ) -> Result<R, Self::RunError>

Constructs a new, lifetime-branded Token, and provides it to the closure. Read more
Source§

fn identifier(&self) -> Self::Identifier

Returns the Token’s identifier, which cells may store to allow comparison.
Source§

fn compare(&self, id: &Self::Identifier) -> Result<(), Self::ComparisonError>

Allows the cell to compare its identifier to the Token. Read more
Source§

impl UnscopedToken for RuntimeToken

Source§

type ConstructionError = Infallible

Constructing a token may fail.
Source§

fn try_new() -> Result<Self, Self::ConstructionError>

Constructs a new Token. Read more
Source§

fn new() -> Self
where Self: UnscopedToken<ConstructionError = Infallible>,

Constructs a new Token. This method may be used instead of UnscopedToken::try_new when .

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.