Struct oid_registry::OidRegistry[][src]

pub struct OidRegistry<'a> { /* fields omitted */ }
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 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

Insert a new entry

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

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

Return an Iterator over references to the OidEntry values

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

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
}
This is supported on crate feature crypto only.

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

This is supported on crate feature crypto only.

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

This is supported on crate feature kdf only.

Load all known OIDs for feature kdf in the registry.

This is supported on crate feature ms_spc only.

Load all known OIDs for feature ms_spc in the registry.

This is supported on crate feature nist_algs only.

Load all known OIDs for feature nist_algs in the registry.

This is supported on crate feature pkcs1 only.

Load all known OIDs for feature pkcs1 in the registry.

This is supported on crate feature pkcs12 only.

Load all known OIDs for feature pkcs12 in the registry.

This is supported on crate feature pkcs7 only.

Load all known OIDs for feature pkcs7 in the registry.

This is supported on crate feature pkcs9 only.

Load all known OIDs for feature pkcs9 in the registry.

This is supported on crate feature x509 only.

Load all known OIDs for feature x509 in the registry.

This is supported on crate feature x962 only.

Load all known OIDs for feature x962 in the registry.

Trait Implementations

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.