pub struct BackendRegistry {
backends: BTreeMap<&'static str, Arc<dyn PrimaryBackend>>,
operations: BTreeMap<&'static str, Arc<dyn DatabaseOperations>>,
}Expand description
Immutable registry of primary backends available to the runtime.
§Fields
- This type stores module-owned state for
crate::backend_registry::BackendRegistry.
§Examples
let _ = std::mem::size_of::<pharos_runtime_integrations::backend_registry::BackendRegistry>();§Related
crate::backend_registryfor constructors, helpers, and neighboring runtime types.
Fields§
§backends: BTreeMap<&'static str, Arc<dyn PrimaryBackend>>§operations: BTreeMap<&'static str, Arc<dyn DatabaseOperations>>Implementations§
Source§impl BackendRegistry
impl BackendRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates one empty backend registry.
§Returns
Returns the computed value produced by [crate::backend_registry::new].
§Examples
let _result = pharos_runtime_integrations::backend_registry::new();§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.
Sourcepub fn register(
&mut self,
backend: Arc<dyn PrimaryBackend>,
) -> Result<(), BackendError>
pub fn register( &mut self, backend: Arc<dyn PrimaryBackend>, ) -> Result<(), BackendError>
Registers one primary backend under its stable backend name.
§Parameters
backend: Input consumed by [crate::backend_registry::register].
§Returns
Returns the successful value produced by [crate::backend_registry::register] or an error when the operation fails.
§Errors
Returns an error value when [crate::backend_registry::register] cannot complete successfully.
§Examples
let _result = pharos_runtime_integrations::backend_registry::register(todo!());§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.
Sourcepub fn register_operations(
&mut self,
name: &'static str,
adapter: Arc<dyn DatabaseOperations>,
) -> Result<(), DatabaseError>
pub fn register_operations( &mut self, name: &'static str, adapter: Arc<dyn DatabaseOperations>, ) -> Result<(), DatabaseError>
Registers the executable operations for one backend in this same registry.
Sourcepub fn resolve_operations(
&self,
name: &str,
) -> Result<Arc<dyn DatabaseOperations>, DatabaseError>
pub fn resolve_operations( &self, name: &str, ) -> Result<Arc<dyn DatabaseOperations>, DatabaseError>
Resolves an executable adapter; metadata registration alone cannot satisfy it. Invalid names are input errors; a valid but unregistered name is unavailable.
Sourcepub fn resolve(
&self,
name: &str,
) -> Result<Arc<dyn PrimaryBackend>, BackendError>
pub fn resolve( &self, name: &str, ) -> Result<Arc<dyn PrimaryBackend>, BackendError>
Resolves one backend by its stable config name.
§Parameters
name: Input consumed by [crate::backend_registry::resolve].
§Returns
Returns the successful value produced by [crate::backend_registry::resolve] or an error when the operation fails.
§Errors
Returns an error value when [crate::backend_registry::resolve] cannot complete successfully.
§Examples
let _result = pharos_runtime_integrations::backend_registry::resolve("name");§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.
Sourcepub fn resolve_kind(
&self,
kind: BackendKind,
) -> Result<Arc<dyn PrimaryBackend>, BackendError>
pub fn resolve_kind( &self, kind: BackendKind, ) -> Result<Arc<dyn PrimaryBackend>, BackendError>
Resolves one backend by typed backend kind.
§Parameters
kind: Input consumed by [crate::backend_registry::resolve_kind].
§Returns
Returns the successful value produced by [crate::backend_registry::resolve_kind] or an error when the operation fails.
§Errors
Returns an error value when [crate::backend_registry::resolve_kind] cannot complete successfully.
§Examples
let _result = pharos_runtime_integrations::backend_registry::resolve_kind(todo!());§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Returns whether the registry contains the named backend.
§Parameters
name: Input consumed by [crate::backend_registry::contains].
§Returns
Returns true when the condition checked by [crate::backend_registry::contains] holds and false otherwise.
§Examples
let _result = pharos_runtime_integrations::backend_registry::contains("name");§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of registered backends.
§Returns
Returns the computed value produced by [crate::backend_registry::len].
§Examples
let _result = pharos_runtime_integrations::backend_registry::len();§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether no backends are registered.
§Returns
Returns true when the condition checked by [crate::backend_registry::is_empty] holds and false otherwise.
§Examples
let _result = pharos_runtime_integrations::backend_registry::is_empty();§Related
crate::backend_registryfor adjacent helpers that share the same runtime surface.