pub struct StableCell<T: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
StableCell
An application value cached in memory and persisted in an exclusive Storage allocation. Dropping the Cell releases its lease without changing its bytes.
Implementations§
Source§impl<T: Storable, M: Memory> StableCell<T, M>
impl<T: Storable, M: Memory> StableCell<T, M>
Sourcepub fn create(
memory: RuntimeMemory<M>,
value: T,
) -> Result<Self, CollectionError>
pub fn create( memory: RuntimeMemory<M>, value: T, ) -> Result<Self, CollectionError>
Create a Cell only in an empty allocation.
§Errors
Returns NotEmpty without mutation if the allocation is nonempty, or
Growth if its initial reservation cannot accommodate the encoding.
§Panics
Panics if encoding fails, violates the declared bound, or backing IO fails. A native mutation panic poisons the backing owner.
Sourcepub fn reset(
memory: RuntimeMemory<M>,
value: T,
) -> Result<Self, CollectionError>
pub fn reset( memory: RuntimeMemory<M>, value: T, ) -> Result<Self, CollectionError>
Sourcepub fn load(
memory: RuntimeMemory<M>,
maximum: usize,
) -> Result<Self, CollectionError>
pub fn load( memory: RuntimeMemory<M>, maximum: usize, ) -> Result<Self, CollectionError>
Open a Cell without modifying its allocation.
The smaller of maximum and the type’s declared ceiling is checked
before allocating or reading the application payload.
§Errors
Returns a Cell framing error if framing, extent or size admission fails.
§Panics
Panics if decoding fails, the length violates a fixed-size codec bound, or backing IO fails. Decode failure releases the lease without poisoning the owner or changing the persisted image.