pub struct Persistent { /* private fields */ }
Implementations§
Source§impl Persistent
impl Persistent
pub fn has<K>(&self, key: &K) -> bool
pub fn get<K, V>(&self, key: &K) -> Option<V>
pub fn set<K, V>(&self, key: &K, val: &V)
Sourcepub fn update<K, V>(&self, key: &K, f: impl FnOnce(Option<V>) -> V) -> V
pub fn update<K, V>(&self, key: &K, f: impl FnOnce(Option<V>) -> V) -> V
Update a value stored against a key.
Loads the value, calls the function with it, then sets the value to the returned value of the function. If no value is stored with the key then the function is called with None.
The returned value is the value stored after updating.
Sourcepub fn try_update<K, V, E>(
&self,
key: &K,
f: impl FnOnce(Option<V>) -> Result<V, E>,
) -> Result<V, E>
pub fn try_update<K, V, E>( &self, key: &K, f: impl FnOnce(Option<V>) -> Result<V, E>, ) -> Result<V, E>
Update a value stored against a key.
Loads the value, calls the function with it, then sets the value to the returned value of the function. If no value is stored with the key then the function is called with None. If the function returns an error it will be passed through.
The returned value is the value stored after updating.
Sourcepub fn extend_ttl<K>(&self, key: &K, threshold: u32, extend_to: u32)
pub fn extend_ttl<K>(&self, key: &K, threshold: u32, extend_to: u32)
Extend the TTL of the data under the key.
Extends the TTL only if the TTL for the provided data is below threshold
ledgers.
The TTL will then become extend_to
.
The TTL is the number of ledgers between the current ledger and the final ledger the data can still be accessed.
pub fn remove<K>(&self, key: &K)
Trait Implementations§
Source§impl Persistent for Persistent
Available on crate feature testutils
only.
impl Persistent for Persistent
testutils
only.Auto Trait Implementations§
impl Freeze for Persistent
impl !RefUnwindSafe for Persistent
impl !Send for Persistent
impl !Sync for Persistent
impl Unpin for Persistent
impl !UnwindSafe for Persistent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more