[−][src]Struct orga::state::Value
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,
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<S, T> Send for Value<S, T> where
S: Send,
T: Send,
S: Send,
T: Send,
impl<S, T> Sync for Value<S, T> where
S: Sync,
T: Sync,
S: Sync,
T: Sync,
impl<S, T> Terminated for Value<S, T> where
S: Terminated,
T: Terminated,
S: Terminated,
T: Terminated,
impl<S, T> Unpin for Value<S, T> where
S: Unpin,
T: Unpin,
S: Unpin,
T: Unpin,
impl<S, T> UnwindSafe for Value<S, T> where
S: UnwindSafe,
T: UnwindSafe,
S: 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,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,