1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::*;

#[macro_export]
macro_rules! cache_field {
    ($name:ident($this:ident, $logger:ident) -> $type:ty $code:block) => {
        #[allow(unused_mut)]
        pub fn $name(&mut self, mut $logger: impl Logger) -> &$type {
            let $this = self;
            if $this.$name.is_none() {
                $this.$name = Some($code);
            }; $this.$name.as_ref().unwrap()
        }
    }
}

#[allow(drop_bounds)]
pub trait LazyObject: Drop {
    fn as_container(&self) -> LazyContainer;
    fn store_lazy(&self) -> Result<(), LDBError>;
    fn load_lazy(container: LazyContainer) -> Self;
    fn clear_cache(&mut self);
}