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,
migrations: RepositoryMigrations,
) -> Result<(), StateRegistryError>
pub async fn initialize_database( &self, configuration: DatabaseConfiguration, migrations: RepositoryMigrations, ) -> 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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Read more