[][src]Struct orga::state::Value

pub struct Value<S: Read, T: Encode + Decode> { /* fields omitted */ }

A simple implementation of State which gets or sets a single value, automatically decoding when getting and encoding when setting.

Implementations

impl<S: Read, T: Encode + Decode> Value<S, T>[src]

pub fn get(&self) -> Result<T, Error>[src]

Gets the stored value, erroring if it does not yet exist.

pub fn maybe_get(&self) -> Result<Option<T>, Error>[src]

Gets the stored value, returning None if it does not yet exist.

impl<S: Read, T: Encode + Decode + Default> Value<S, T>[src]

pub fn get_or_default(&self) -> Result<T, Error>[src]

Gets the stored value, returning the default if it does not yet exist.

impl<S: Store, T: Encode + Decode> Value<S, T>[src]

pub fn set<B: Borrow<T>>(&mut self, value: B) -> Result<(), Error>[src]

Sets the value and writes it to the store, replacing it if it already exists.

Trait Implementations

impl<S: Read, T: Encode + Decode> State<S> for Value<S, T>[src]

fn wrap_store(store: S) -> Result<Value<S, T>, Error>[src]

Constructs a Value by wrapping a store instance.

Auto Trait Implementations

impl<S, T> RefUnwindSafe for Value<S, T> where
    S: RefUnwindSafe,
    T: RefUnwindSafe

impl<S, T> Send for Value<S, T> where
    S: Send,
    T: Send

impl<S, T> Sync for Value<S, T> where
    S: Sync,
    T: Sync

impl<S, T> Terminated for Value<S, T> where
    S: Terminated,
    T: Terminated

impl<S, T> Unpin for Value<S, T> where
    S: Unpin,
    T: Unpin

impl<S, T> UnwindSafe for Value<S, T> where
    S: UnwindSafe,
    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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,