Skip to main content

DataSourceCatalog

Struct DataSourceCatalog 

Source
pub struct DataSourceCatalog { /* private fields */ }
Expand description

业务作用:作为单个 Application 的冻结 datasource 名称与 driver 权威。

Implementations§

Source§

impl DataSourceCatalog

Source

pub fn try_new( owner: ManagedRegistryOwner, entries: impl IntoIterator<Item = (String, DatabaseDriver)>, ) -> Result<Self, CatalogBuildError>

业务作用:构造尚未对 getter 开放的冻结 catalog。

参数说明:

  • owner:本次 Application 的共同 owner。
  • entries:datasource qualifier 与 driver 的完整集合。

返回:名称合法、不重复、非空且数量有界时返回关闭态 catalog;失败不发布部分表。

Source

pub fn owner(&self) -> &ManagedRegistryOwner

业务作用:读取 catalog 绑定的 Application owner。

参数说明: 无。

返回:共同 owner 的只读引用。

Source

pub fn len(&self) -> usize

业务作用:返回冻结 catalog 的 datasource 数量。

参数说明: 无。

返回:跨 driver 合计的条目数。

Source

pub fn is_empty(&self) -> bool

业务作用:判断 catalog 是否没有 datasource。

参数说明: 无。

返回:构造成功后固定为假;该入口供通用容器检查使用。

Source

pub fn entries(&self) -> Vec<(DatasourceRef, DatabaseDriver)>

业务作用:复制冻结后的 datasource 与 driver 表,供资源登记和观测快照使用。

参数说明: 无。

返回:按 datasource 名排序的拥有型条目。

Source

pub fn resolve( &self, datasource: &str, expected: DatabaseDriver, ) -> Result<DatasourceRef, DataSourceLookupError>

业务作用:在 catalog 已开放时解析名称并复验调用方期待的 driver。

参数说明:

  • datasource:待解析名称。
  • expected:typed getter 对应的 driver。

返回:名称和 driver 同时匹配时返回规范引用;关闭、缺失或错配时返回结构化错误。

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more