Skip to main content

BackendRegistry

Struct BackendRegistry 

Source
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

§Examples

ⓘ
let _ = std::mem::size_of::<pharos_runtime_integrations::backend_registry::BackendRegistry>();

Fields§

§backends: BTreeMap<&'static str, Arc<dyn PrimaryBackend>>§operations: BTreeMap<&'static str, Arc<dyn DatabaseOperations>>

Implementations§

Source§

impl BackendRegistry

Source

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();
Source

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!());
Source

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.

Source

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.

Source

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");
Source

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!());
Source

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");
Source

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();
Source

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();

Trait Implementations§

Source§

impl Default for BackendRegistry

Source§

fn default() -> BackendRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.