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>
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