Struct near_sdk::collections::LazyOption[][src]

pub struct LazyOption<T> { /* fields omitted */ }

An persistent lazy option, that stores a value in the storage.

Implementations

impl<T> LazyOption<T>[src]

pub fn is_some(&self) -> bool[src]

Returns true if the value is present in the storage.

pub fn is_none(&self) -> bool[src]

Returns true if the value is not present in the storage.

impl<T> LazyOption<T> where
    T: BorshSerialize + BorshDeserialize
[src]

pub fn new<S>(storage_key: S, value: Option<&T>) -> Self where
    S: IntoStorageKey
[src]

Create a new lazy option with the given storage_key and the initial value.

pub fn remove(&mut self) -> bool[src]

Removes the value from storage without reading it. Returns whether the value was present.

pub fn take(&mut self) -> Option<T>[src]

Removes the value from storage and returns it as an option.

pub fn get(&self) -> Option<T>[src]

Gets the value from storage and returns it as an option.

pub fn set(&mut self, value: &T) -> bool[src]

Sets the value into the storage without reading the previous value and returns whether the previous value was present.

pub fn replace(&mut self, value: &T) -> Option<T>[src]

Replaces the value in the storage and returns the previous value as an option.

Trait Implementations

impl<T> BorshDeserialize for LazyOption<T> where
    Vec<u8>: BorshDeserialize
[src]

impl<T> BorshSerialize for LazyOption<T> where
    Vec<u8>: BorshSerialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for LazyOption<T> where
    T: RefUnwindSafe

impl<T> Send for LazyOption<T> where
    T: Send

impl<T> Sync for LazyOption<T> where
    T: Sync

impl<T> Unpin for LazyOption<T> where
    T: Unpin

impl<T> UnwindSafe for LazyOption<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.