pub struct StateBox<T: Serial, S: HasStateApi> { /* private fields */ }
Expand description

A pointer type for data in the state.

The actual data is lazily loaded and thereafter cached in memory.

Due to its laziness, a StateBox can be used to defer loading of data in your state. This is useful when part of your state isn’t used in every receive method.

The type parameter T is the type stored in the box. The type parameter S is the state.

Implementations

Get a reference to the value.

Get a mutable reference to the value. If the value is modified in-memory then it will be stored when the box is dropped.

Replace the value with the provided one. The current value is returned. Note that if the type T contains references to state, e.g., is a StateBox, then it must be deleted to avoid space leaks.

Update the existing value with the given function. The supplied function may return some data, which is then returned by update.

Trait Implementations

Formats the value using the given formatter. Read more

Delete all items that this type owns in the state.

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Attempt to read a structure from a given source and state, failing if an error occurs during deserialization or reading. Read more

Executes the destructor for this type. Read more

Attempt to write the structure into the provided writer, failing if only part of the structure could be written. Read more

Make a clone of the type while using the cloned_state_api. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.