The handler model (inputs, events, replies), aggregates, read models, the query builder, the unit of work, migrations, the worker and the database seam.
usestd::any::{Any, TypeId};usestd::collections::HashMap;usestd::sync::{Arc, RwLock};usesofie_core::unpoisoned;typeEntries=HashMap<TypeId, Arc<dyn Any +Send+Sync>>;/// Shared by every clone of one `Db`, so what is provided after a clone is seen by it too.
#[derive(Default)]pub(crate)structProvided(RwLock<Entries>);implProvided{pub(crate)fnget<T: Any +Send+Sync>(&self)->Option<Arc<T>>{let entries =unpoisoned::read(&self.0);
entries.get(&TypeId::of::<T>())?.clone().downcast().ok()}pub(crate)fnchange<T: Any +Send+Sync+Clone+Default>(&self,
change: impl FnOnce(&mutT),
){letmut entries =unpoisoned::write(&self.0);let entry = entries
.entry(TypeId::of::<T>()).or_insert_with(||Arc::new(T::default()));letmut value = entry.downcast_ref::<T>().cloned().unwrap_or_default();change(&mut value);*entry =Arc::new(value);}}