pub struct Var<T> { /* private fields */ }Expand description
Data structure for storing a single value.
Implementations§
Source§impl<T> Var<T>
impl<T> Var<T>
Sourcepub fn env(&self) -> ContractEnv
pub fn env(&self) -> ContractEnv
Returns the contract environment associated with the variable.
Source§impl<T: FromBytes> Var<T>
impl<T: FromBytes> Var<T>
Sourcepub fn get(&self) -> Option<T>
pub fn get(&self) -> Option<T>
Retrieves the value of the variable.
Returns Some(value) if the variable has a value, or None if it is unset.
Sourcepub fn get_or_revert_with<E: Into<OdraError>>(&self, error: E) -> T
pub fn get_or_revert_with<E: Into<OdraError>>(&self, error: E) -> T
Retrieves the value of the variable or reverts with an error.
If the variable has a value, it is returned. Otherwise, the provided error is reverted.
Source§impl<T: FromBytes + Default> Var<T>
impl<T: FromBytes + Default> Var<T>
Sourcepub fn get_or_default(&self) -> T
pub fn get_or_default(&self) -> T
Returns the value of the variable, or the default value of the type if the variable is None.
Trait Implementations§
Source§impl<T> ModuleComponent for Var<T>
Implements the ModuleComponent trait for the Var struct.
impl<T> ModuleComponent for Var<T>
Implements the ModuleComponent trait for the Var struct.
Source§impl<T> Revertible for Var<T>
impl<T> Revertible for Var<T>
impl<T> ModulePrimitive for Var<T>
Auto Trait Implementations§
impl<T> Freeze for Var<T>
impl<T> !RefUnwindSafe for Var<T>
impl<T> !Send for Var<T>
impl<T> !Sync for Var<T>
impl<T> Unpin for Var<T>where
T: Unpin,
impl<T> !UnwindSafe for Var<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<M> HasEvents for Mwhere
M: ModulePrimitive,
impl<M> HasEvents for Mwhere
M: ModulePrimitive,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more