Struct matterdb::Lazy [−][src]
pub struct Lazy<T, I> { /* fields omitted */ }
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()) );
Implementations
impl<T, I> Lazy<T, I> where
T: Access,
I: FromAccess<T>,
[src]
impl<T, I> Lazy<T, I> where
T: Access,
I: FromAccess<T>,
[src]Trait Implementations
impl<T, I> FromAccess<T> for Lazy<T, I> where
T: Access,
I: FromAccess<T>,
[src]
impl<T, I> FromAccess<T> for Lazy<T, I> where
T: Access,
I: FromAccess<T>,
[src]fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]Constructs the object at the given address. Read more
fn from_root(access: T) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]Constructs the object from the root of the access
. Read more
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T