pub struct Instance { /* private fields */ }
Implementations§
Source§impl Instance
impl Instance
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.
pub fn remove<K>(&self, key: &K)
Sourcepub fn extend_ttl(&self, threshold: u32, extend_to: u32)
pub fn extend_ttl(&self, threshold: u32, extend_to: u32)
Extend the TTL of the contract instance and code.
Extends the TTL of the instance and code only if the TTL for the provided contract is below threshold
ledgers.
The TTL will then become extend_to
. Note that the threshold
check and TTL extensions are done for both the
contract code and contract instance, so it’s possible that one is bumped but not the other depending on what the
current TTL’s are.
The TTL is the number of ledgers between the current ledger and the final ledger the data can still be accessed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Instance
impl !RefUnwindSafe for Instance
impl !Send for Instance
impl !Sync for Instance
impl Unpin for Instance
impl !UnwindSafe for Instance
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