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> Var<T>where
T: FromBytes,
impl<T> Var<T>where
T: FromBytes,
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>(&self, error: E) -> T
pub fn get_or_revert_with<E>(&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> Var<T>
impl<T> 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<M> SchemaErrors for Var<M>where
M: SchemaErrors,
impl<M> SchemaErrors for Var<M>where
M: SchemaErrors,
source§impl<M> SchemaEvents for Var<M>where
M: SchemaEvents,
impl<M> SchemaEvents for Var<M>where
M: SchemaEvents,
source§fn custom_types() -> Vec<Option<CustomType>>
fn custom_types() -> Vec<Option<CustomType>>
Returns a vector of CustomTypes. Read more
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