[][src]Struct oid_registry::OidRegistry

pub struct OidRegistry { /* fields omitted */ }

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 der_parser::{oid, 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 OidRegistry[src]

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

Insert a new entry

pub fn get(&self, oid: &Oid<'static>) -> Option<&OidEntry>[src]

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

pub fn keys(&self) -> impl Iterator<Item = &Oid<'static>>[src]

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

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

Return an Iterator over references to the OidEntry values

pub fn iter(&self) -> impl Iterator<Item = (&Oid<'static>, &OidEntry)>[src]

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

pub fn iter_by_sn<S: Into<String>>(
    &self,
    sn: S
) -> impl Iterator<Item = (&Oid<'static>, &OidEntry)>
[src]

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) -> Self[src]

This is supported on crate feature crypto only.

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

pub fn with_all_crypto(self) -> Self[src]

This is supported on crate feature crypto only.

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

impl OidRegistry[src]

pub fn with_x509(self) -> Self[src]

This is supported on crate feature x509 only.

Load all known OIDs for feature x509 in the registry.

pub fn with_kdf(self) -> Self[src]

This is supported on crate feature kdf only.

Load all known OIDs for feature kdf in the registry.

pub fn with_nist_algs(self) -> Self[src]

This is supported on crate feature nist_algs only.

Load all known OIDs for feature nist_algs in the registry.

pub fn with_x962(self) -> Self[src]

This is supported on crate feature x962 only.

Load all known OIDs for feature x962 in the registry.

pub fn with_ms_spc(self) -> Self[src]

This is supported on crate feature ms_spc only.

Load all known OIDs for feature ms_spc in the registry.

pub fn with_pkcs1(self) -> Self[src]

This is supported on crate feature pkcs1 only.

Load all known OIDs for feature pkcs1 in the registry.

pub fn with_pkcs7(self) -> Self[src]

This is supported on crate feature pkcs7 only.

Load all known OIDs for feature pkcs7 in the registry.

pub fn with_pkcs9(self) -> Self[src]

This is supported on crate feature pkcs9 only.

Load all known OIDs for feature pkcs9 in the registry.

Trait Implementations

impl Debug for OidRegistry[src]

impl Default for OidRegistry[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.