pub struct StateRegistry {
sdk_managed: RwLock<Vec<RepositoryItemData>>,
client_managed: RwLock<HashMap<TypeId, Box<dyn Any + Send + Sync>>>,
database: OnceLock<SqliteDatabase>,
}
Expand description
A registry that contains repositories for different types of items. These repositories can be either managed by the client or by the SDK itself.
Fields§
§sdk_managed: RwLock<Vec<RepositoryItemData>>
§client_managed: RwLock<HashMap<TypeId, Box<dyn Any + Send + Sync>>>
§database: OnceLock<SqliteDatabase>
Implementations§
Source§impl StateRegistry
impl StateRegistry
Sourcepub async fn initialize_database(
&self,
configuration: DatabaseConfiguration,
repositories: Vec<RepositoryItemData>,
) -> Result<(), StateRegistryError>
pub async fn initialize_database( &self, configuration: DatabaseConfiguration, repositories: Vec<RepositoryItemData>, ) -> Result<(), StateRegistryError>
Initializes the database used for sdk-managed repositories.
Sourcepub fn register_client_managed<T: RepositoryItem>(
&self,
value: Arc<dyn Repository<T>>,
)
pub fn register_client_managed<T: RepositoryItem>( &self, value: Arc<dyn Repository<T>>, )
Registers a client-managed repository into the map, associating it with its type.
Sourcepub fn get_client_managed<T: RepositoryItem>(
&self,
) -> Result<Arc<dyn Repository<T>>, RepositoryNotFoundError>
pub fn get_client_managed<T: RepositoryItem>( &self, ) -> Result<Arc<dyn Repository<T>>, RepositoryNotFoundError>
Retrieves a client-managed repository from the map given its type.
Sourcepub fn get_sdk_managed<T: RepositoryItem + Serialize + DeserializeOwned>(
&self,
) -> Result<impl Repository<T>, StateRegistryError>
pub fn get_sdk_managed<T: RepositoryItem + Serialize + DeserializeOwned>( &self, ) -> Result<impl Repository<T>, StateRegistryError>
Retrieves a SDK-managed repository from the database.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for StateRegistry
impl !RefUnwindSafe for StateRegistry
impl Send for StateRegistry
impl Sync for StateRegistry
impl Unpin for StateRegistry
impl !UnwindSafe for StateRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more