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) -> Self
pub fn create(memory: RuntimeMemory<M>, value: T) -> Self
Sourcepub fn reset(memory: RuntimeMemory<M>, value: T) -> Self
pub fn reset(memory: RuntimeMemory<M>, value: T) -> Self
Explicitly replace an allocation’s contents with a new Cell.
§Panics
Panics on encoding, backing or growth failure.
Sourcepub fn load(memory: RuntimeMemory<M>) -> Result<Self, StableCellPayloadError>
pub fn load(memory: RuntimeMemory<M>) -> Result<Self, StableCellPayloadError>
Open a Cell without modifying its allocation.
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 writing.
Auto Trait Implementations§
impl<T, M = Rc<RefCell<Vec<u8>>>> !RefUnwindSafe for StableCell<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !Send for StableCell<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !Sync for StableCell<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !UnwindSafe for StableCell<T, M>
impl<T, M> Forget for StableCell<T, M>
impl<T, M> Freeze for StableCell<T, M>
impl<T, M> Move for StableCell<T, M>
impl<T, M> Unpin for StableCell<T, M>
impl<T, M> UnsafeUnpin for StableCell<T, M>
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
Mutably borrows from an owned value. Read more