better_auth_core/
runtime_extensions.rs1use std::{
2 any::{Any, TypeId},
3 collections::HashMap,
4 sync::Arc,
5};
6
7#[derive(Clone, Default)]
9pub struct RuntimeExtensions(HashMap<TypeId, Arc<dyn Any + Send + Sync>>);
10
11impl RuntimeExtensions {
12 pub fn insert<T: Send + Sync + 'static>(&mut self, value: T) {
14 let _ = self.0.insert(TypeId::of::<T>(), Arc::new(value));
15 }
16
17 pub fn get<T: Send + Sync + 'static>(&self) -> Option<&T> {
19 self.0.get(&TypeId::of::<T>())?.downcast_ref()
20 }
21}