[][src]Struct eosio_cdt::SingletonIndex

pub struct SingletonIndex<T: Table>(_);

TODO docs

Methods

impl<T: Table> SingletonIndex<T>[src]

pub fn new<C, S>(code: C, scope: S) -> Self where
    C: Into<AccountName>,
    S: Into<ScopeName>, 
[src]

TODO docs

#[must_use] pub fn exists(&self) -> bool[src]

Checks if the singleton entry exists

#[must_use] pub fn get(&self) -> Option<Result<T::Row, ReadError>>[src]

Gets the value stored inside the singleton. Returns None if no value is found, or ReadError if there was an issue reading the data.

pub fn get_or_default(&self) -> Result<T::Row, ReadError> where
    T::Row: Default
[src]

Gets the value stored inside the singleton or returns the default value.

Errors

Will return Err if there was an issue deserializing the stored value.

pub fn set(&self, value: &T::Row, payer: AccountName) -> Result<(), WriteError>[src]

Sets the singleton value

Errors

Will return Err if there was an issue serializing the value.

pub fn remove(&self) -> Result<Option<T::Row>, ReadError>[src]

Removes the singleton value if it exists. Returns ReadError if there was an issue reading the data, and None if there was no entry found

Errors

Will return Err if there was an issue reading the stored value.

Auto Trait Implementations

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

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

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

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