1use crate::*;
2
3#[macro_export]
4macro_rules! cache_field {
5 ($name:ident($this:ident, $logger:ident) -> $type:ty $code:block) => {
6 #[allow(unused_mut)]
7 pub fn $name(&mut self, mut $logger: impl Logger) -> &mut $type {
8 let $this = self;
9 if $this.$name.is_none() {
10 $this.$name = Some($code);
11 }; $this.$name.as_mut().unwrap()
12 }
13 }
14}
15
16#[allow(drop_bounds)]
17pub trait LazyObject: Drop {
18 fn as_container(&self) -> &LazyContainer;
19 fn store_lazy(&self) -> Result<(), LDBError>;
20 fn load_lazy(container: LazyContainer) -> Self;
21 fn clear_cache(&mut self);
22}