OidRegistry

Struct OidRegistry 

pub struct OidRegistry<'a> { /* private fields */ }
Available on crate feature crypto only.
Expand description

Registry of known OIDs

Use OidRegistry::default() to create an empty registry. If the corresponding features have been selected, the with_xxx() methods can be used to add sets of known objets to the database.

§Example

use asn1_rs::{oid, Oid};
use oid_registry::{OidEntry, OidRegistry};

let mut registry = OidRegistry::default()
    .with_crypto() // only if the 'crypto' feature is enabled
;

// entries can be added by creating an OidEntry object:
let entry = OidEntry::new("shortName", "description");
registry.insert(oid!(1.2.3.4), entry);

// when using static strings, a tuple can also be used directly for the entry:
registry.insert(oid!(1.2.3.5), ("shortName", "A description"));

// To query an entry, use the `get` method:
const OID_1234: Oid<'static> = oid!(1.2.3.4);
let e = registry.get(&OID_1234);
assert!(e.is_some());
if let Some(e) = e {
    assert_eq!(e.sn(), "shortName");
}

Implementations§

§

impl<'a> OidRegistry<'a>

pub fn insert<E>(&mut self, oid: Oid<'a>, entry: E) -> Option<OidEntry>
where E: Into<OidEntry>,

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Insert a new entry

pub fn get(&self, oid: &Oid<'a>) -> Option<&OidEntry>

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Returns a reference to the registry entry, if found for this OID.

pub fn keys(&self) -> impl Iterator<Item = &Oid<'a>>

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Return an Iterator over references to the OID numbers (registry keys)

pub fn values(&self) -> impl Iterator<Item = &OidEntry>

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Return an Iterator over references to the OidEntry values

pub fn iter(&self) -> impl Iterator<Item = (&Oid<'a>, &OidEntry)>

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Return an Iterator over references to the (Oid, OidEntry) key/value pairs

pub fn iter_by_sn<S>( &self, sn: S, ) -> impl Iterator<Item = (&Oid<'a>, &OidEntry)>
where S: Into<String>,

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Return the (Oid, OidEntry) key/value pairs, matching a short name

The registry should not contain entries with same short name to avoid ambiguity, but it is not mandatory.

This function returns an iterator over the key/value pairs. In most cases, it will have 0 (not found) or 1 item, but can contain more if there are multiple definitions.

// iterate all entries matching "shortName"
for (oid, entry) in registry.iter_by_sn("shortName") {
    // do something
}

// if you are *sure* that there is at most one entry:
let opt_sn = registry.iter_by_sn("shortName").next();
if let Some((oid, entry)) = opt_sn {
    // do something
}

pub fn with_crypto(self) -> OidRegistry<'a>

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Populate registry with common crypto OIDs (encryption, hash algorithms)

pub fn with_all_crypto(self) -> OidRegistry<'a>

Available on (crate features rustls or boring or acme) and crate feature rustls only.

Populate registry with all known crypto OIDs (encryption, hash algorithms, PKCS constants, etc.)

§

impl OidRegistry<'_>

pub fn with_kdf(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature kdf only.

Load all known OIDs for feature kdf in the registry.

pub fn with_nist_algs(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature nist_algs only.

Load all known OIDs for feature nist_algs in the registry.

pub fn with_pkcs1(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature pkcs1 only.

Load all known OIDs for feature pkcs1 in the registry.

pub fn with_pkcs12(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature pkcs12 only.

Load all known OIDs for feature pkcs12 in the registry.

pub fn with_pkcs7(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature pkcs7 only.

Load all known OIDs for feature pkcs7 in the registry.

pub fn with_pkcs9(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature pkcs9 only.

Load all known OIDs for feature pkcs9 in the registry.

pub fn with_x509(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature x509 only.

Load all known OIDs for feature x509 in the registry.

pub fn with_x962(self) -> OidRegistry<'_>

Available on (crate features rustls or boring or acme) and crate feature rustls and crate feature registry and crate feature x962 only.

Load all known OIDs for feature x962 in the registry.

Trait Implementations§

§

impl<'a> Debug for OidRegistry<'a>

§

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

Formats the value using the given formatter. Read more
§

impl<'a> Default for OidRegistry<'a>

§

fn default() -> OidRegistry<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for OidRegistry<'a>

§

impl<'a> RefUnwindSafe for OidRegistry<'a>

§

impl<'a> Send for OidRegistry<'a>

§

impl<'a> Sync for OidRegistry<'a>

§

impl<'a> Unpin for OidRegistry<'a>

§

impl<'a> UnwindSafe for OidRegistry<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

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

§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

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

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

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

§

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

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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