[−][src]Struct exonum_merkledb::Lazy
Lazily initialized object in the database.
Unlike eagerly initialized objects, lazy ones are not accessed until a get()
method
is called; thus, construction of a lazy object is cheap.
This can be used to improve performance of a database object, some components of which
are rarely accessed.
Note that Group
s are already lazy, so it does not make sense to wrap a one into Lazy<_>
(although this is technically possible).
Examples
let db = TemporaryDB::new(); let fork = db.fork(); { let lazy: Lazy<_, ListIndex<_, String>> = Lazy::from_access(&fork, "lazy_list".into()).unwrap(); lazy.get().push("!".to_owned()); assert_eq!(lazy.get().len(), 1); } // List can then be accessed eagerly. assert_eq!( fork.get_list::<_, String>("lazy_list").get(0), Some("!".to_owned()) );
Methods
impl<T, I> Lazy<T, I> where
T: Access,
I: FromAccess<T>,
[src]
T: Access,
I: FromAccess<T>,
pub fn get(&self) -> I
[src]
pub fn try_get(&self) -> Result<I, AccessError>
[src]
Tries to restore the object from the database.
Trait Implementations
impl<T: Debug, I: Debug> Debug for Lazy<T, I>
[src]
impl<T, I> FromAccess<T> for Lazy<T, I> where
T: Access,
I: FromAccess<T>,
[src]
T: Access,
I: FromAccess<T>,
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]
Auto Trait Implementations
impl<T, I> RefUnwindSafe for Lazy<T, I> where
I: RefUnwindSafe,
T: RefUnwindSafe,
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, I> Send for Lazy<T, I> where
I: Send,
T: Send,
I: Send,
T: Send,
impl<T, I> Sync for Lazy<T, I> where
I: Sync,
T: Sync,
I: Sync,
T: Sync,
impl<T, I> Unpin for Lazy<T, I> where
I: Unpin,
T: Unpin,
I: Unpin,
T: Unpin,
impl<T, I> UnwindSafe for Lazy<T, I> where
I: UnwindSafe,
T: UnwindSafe,
I: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,