Skip to main content

Registry

Struct Registry 

Source
pub struct Registry<T> { /* private fields */ }
Expand description

泛型注册表:Registry<Box<dyn SymmetricCipher>> 等。

注册表按 item.identifier() 存储;相同标识重复注册以最后一次为准。 kind 仅用于错误消息(如 “symmetric cipher”)。

Implementations§

Source§

impl<T: Identified> Registry<T>

Source

pub fn new(kind: &'static str) -> Self

kind:错误消息里的能力名称,如 “symmetric cipher”。

Source

pub fn register(&mut self, item: T) -> &mut Self

以 item.identifier() 为键注册/覆盖。

Source

pub fn has(&self, identifier: &str) -> bool

Source

pub fn get(&self, identifier: &str) -> Result<&T>

Source

pub fn identifiers(&self) -> Vec<&str>

已注册标识,按字典序。

Trait Implementations§

Source§

impl<T: Identified> Debug for Registry<T>

只打印能力名与标识列表;不要求 T: Debug(实现内部持有密钥)。

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Registry<T>
where BTreeMap<String, T>: Freeze,

§

impl<T> RefUnwindSafe for Registry<T>

§

impl<T> Send for Registry<T>
where BTreeMap<String, T>: Send,

§

impl<T> Sync for Registry<T>
where BTreeMap<String, T>: Sync,

§

impl<T> Unpin for Registry<T>
where BTreeMap<String, T>: Unpin,

§

impl<T> UnsafeUnpin for Registry<T>

§

impl<T> UnwindSafe for Registry<T>

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

Source§

fn from_<T>(t: T) -> Self
where Self: From<T>,

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

Source§

fn into_<T>(self) -> T
where Self: Into<T>,

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 = !

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

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

Performs the conversion.
Source§

impl<T> TryFromExt for T

Source§

fn try_from_<T>(t: T) -> Result<Self, Self::Error>
where Self: TryFrom<T>,

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

Source§

fn try_into_<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,