anthill_di/
local_context.rs1use std::{
2 any::{
3 Any,
4 TypeId
5 },
6 collections::HashMap,
7 sync::Arc
8};
9
10use crate::types::AnthillRwLock;
11
12#[derive(Default)]
13pub struct LocalContext {
14 pub (crate) local_context: AnthillRwLock<HashMap<TypeId, Arc<AnthillRwLock<Option<Arc<dyn Any + Sync + Send>>>>>>,
15}
16
17impl std::fmt::Debug for LocalContext {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 f.debug_struct("LocalContext")
20 .field("local_context",
21 &self.local_context.try_read().unwrap()
22 .iter().map(|(id, instance)| (id.clone(), if instance.try_read().unwrap().is_none() {"None"} else {"Not Empty"}))
23 .collect::<HashMap<_,_>>()
24 )
25 .finish()
26 }
27}