Struct near_sdk::collections::LazyOption [−][src]
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]
T: BorshSerialize + BorshDeserialize,
pub fn new<S>(storage_key: S, value: Option<&T>) -> Self where
S: IntoStorageKey,
[src]
S: IntoStorageKey,
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]
Vec<u8>: BorshDeserialize,
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
[src]
pub fn try_from_slice(v: &[u8]) -> Result<Self, Error>
[src]
pub fn is_u8() -> bool
[src]
impl<T> BorshSerialize for LazyOption<T> where
Vec<u8>: BorshSerialize,
[src]
Vec<u8>: BorshSerialize,
Auto Trait Implementations
impl<T> RefUnwindSafe for LazyOption<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for LazyOption<T> where
T: Send,
T: Send,
impl<T> Sync for LazyOption<T> where
T: Sync,
T: Sync,
impl<T> Unpin for LazyOption<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for LazyOption<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,