1 pub(crate) trait Counter: salsa::Database { increment(&self) -> usize2 fn increment(&self) -> usize; 3 } 4 5 #[salsa::query_group(GroupStruct)] 6 pub(crate) trait Database: Counter { memoized(&self) -> usize7 fn memoized(&self) -> usize; volatile(&self) -> usize8 fn volatile(&self) -> usize; 9 } 10 11 /// Because this query is memoized, we only increment the counter 12 /// the first time it is invoked. memoized(db: &dyn Database) -> usize13fn memoized(db: &dyn Database) -> usize { 14 db.volatile() 15 } 16 17 /// Because this query is volatile, each time it is invoked, 18 /// we will increment the counter. volatile(db: &dyn Database) -> usize19fn volatile(db: &dyn Database) -> usize { 20 db.salsa_runtime().report_untracked_read(); 21 db.increment() 22 } 23