Lazy

Struct Lazy 

Source
pub struct Lazy<T> { /* private fields */ }
Expand description

Lazy-loaded model.

Implementations§

Source§

impl<T> Lazy<T>

Source

pub fn from_raw(cell: Cell) -> Self

Wraps the cell in a typed wrapper.

Source

pub fn into_inner(self) -> Cell

Converts into the underlying cell.

Source

pub fn inner(&self) -> &Cell

Returns the underlying cell.

Source

pub fn cast_into<Q>(self) -> Lazy<Q>
where Q: EquivalentRepr<T>,

Converts into a lazy loader for an equivalent type.

Source

pub fn cast_ref<Q>(&self) -> &Lazy<Q>
where Q: EquivalentRepr<T>,

Casts itself into a lazy loaded for an equivalent type.

Source

pub fn serialize_repr_hash<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes only the root hash of the cell.

Source§

impl<T: Store> Lazy<T>

Source

pub fn new(data: &T) -> Result<Self, Error>

Serializes the provided data and returns the typed wrapper around it.

Source

pub fn set(&mut self, data: &T) -> Result<(), Error>

Updates the content with the provided data.

Source§

impl<'a, T: Load<'a> + 'a> Lazy<T>

Source

pub fn load(&'a self) -> Result<T, Error>

Loads inner data from cell.

Trait Implementations§

Source§

impl<T> AsRef<dyn CellImpl + Send + Sync> for Lazy<T>

Source§

fn as_ref(&self) -> &DynCell

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Clone for Lazy<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Lazy<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for Lazy<T>
where T: Deserialize<'de> + Store,

Source§

fn deserialize<D>(deserializer: D) -> Result<Lazy<T>, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> ExactSize for Lazy<T>

Source§

fn exact_size(&self) -> Size

Exact size of the value when it is stored in a slice.
Source§

impl<'a, T> Load<'a> for Lazy<T>

Source§

fn load_from(slice: &mut CellSlice<'a>) -> Result<Self, Error>

Tries to load itself from a cell slice.
Source§

impl<T> PartialEq for Lazy<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Lazy<T>
where for<'a> T: Serialize + Load<'a>,

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Store for Lazy<T>

Source§

fn store_into( &self, builder: &mut CellBuilder, _: &mut dyn CellContext, ) -> Result<(), Error>

Tries to store itself into the cell builder.
Source§

impl<T: WithAbiType> WithAbiType for Lazy<T>

Source§

fn abi_type() -> AbiType

Returns a corresponding ABI type.
Source§

impl<T> Eq for Lazy<T>

Auto Trait Implementations§

§

impl<T> Freeze for Lazy<T>

§

impl<T> !RefUnwindSafe for Lazy<T>

§

impl<T> Send for Lazy<T>
where T: Send,

§

impl<T> Sync for Lazy<T>
where T: Sync,

§

impl<T> Unpin for Lazy<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Lazy<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compares self to key and returns true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> EquivalentRepr<T> for T