Skip to main content

BoundedCell

Struct BoundedCell 

Source
pub struct BoundedCell<T: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }
Expand description

A stable cell whose writes enforce the record’s declared Storable bound.

Implementations§

Source§

impl<T: Storable, M: Memory> BoundedCell<T, M>

Source

pub fn init(memory: RuntimeMemory<M>, value: T) -> Self

Open a current cell or initialize a fresh bounded record. Empty memory or foreign magic initializes the supplied value, potentially overwriting foreign contents. Recognized incompatible layouts are refused.

§Panics

Panics for unbounded records or encodings that violate the declared bound. Also retains StableCell::init layout, growth and codec/backing panics.

Source

pub fn get(&self) -> &T

Read the cached current record without serializing or cloning it.

Source

pub fn set(&mut self, value: T) -> T

Validate and persist a complete replacement, returning the prior record.

§Panics

Panics before writing if the encoding violates its declared bound.

Auto Trait Implementations§

§

impl<T, M = Rc<RefCell<Vec<u8>>>> !Freeze for BoundedCell<T, M>

§

impl<T, M = Rc<RefCell<Vec<u8>>>> !RefUnwindSafe for BoundedCell<T, M>

§

impl<T, M = Rc<RefCell<Vec<u8>>>> !Send for BoundedCell<T, M>

§

impl<T, M = Rc<RefCell<Vec<u8>>>> !Sync for BoundedCell<T, M>

§

impl<T, M = Rc<RefCell<Vec<u8>>>> !UnwindSafe for BoundedCell<T, M>

§

impl<T, M> Unpin for BoundedCell<T, M>
where Cell<BoundedValue<T>, RuntimeMemory<M>>: Unpin,

§

impl<T, M> UnsafeUnpin for BoundedCell<T, M>
where Cell<BoundedValue<T>, RuntimeMemory<M>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.