mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-12 16:35:21 +00:00
27 lines
612 B
Rust
27 lines
612 B
Rust
use crate::queries;
|
|
use std::cell::Cell;
|
|
|
|
#[salsa::database(queries::GroupStruct)]
|
|
#[derive(Default)]
|
|
pub(crate) struct DatabaseImpl {
|
|
runtime: salsa::Runtime<DatabaseImpl>,
|
|
counter: Cell<usize>,
|
|
}
|
|
|
|
impl queries::Counter for DatabaseImpl {
|
|
fn increment(&self) -> usize {
|
|
let v = self.counter.get();
|
|
self.counter.set(v + 1);
|
|
v
|
|
}
|
|
}
|
|
|
|
impl salsa::Database for DatabaseImpl {
|
|
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
|
&self.runtime
|
|
}
|
|
|
|
fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<DatabaseImpl> {
|
|
&mut self.runtime
|
|
}
|
|
}
|