Lines Matching full:oid
3 //! [](https://docs.rs/oid-registry)
4 //! [](https://crates.io/crates/oid-r…
5 …(https://github.com/rusticata/oid-registry/workflows/Continuous%20integration/badge.svg)](https://…
7 //! # OID Registry
9 //! This crate is a helper crate, containing a database of OID objects. These objects are intended
13 //! be used to get names and descriptions from OID.
48 //! use der_parser::oid;
54 //! registry.insert(oid!(1.2.3.4), entry);
57 //! registry.insert(oid!(1.2.3.5), ("shortName", "A description"));
63 //! All OID values, constants, and features are derived from files in the `assets` directory in the
78 use der_parser::oid;
79 pub use der_parser::oid::Oid;
88 /// An entry stored in the OID registry
136 /// use der_parser::{oid, oid::Oid};
149 /// registry.insert(oid!(1.2.3.4), entry);
152 /// registry.insert(oid!(1.2.3.5), ("shortName", "A description"));
155 /// const OID_1234: Oid<'static> = oid!(1.2.3.4);
164 map: HashMap<Oid<'a>, OidEntry>,
169 pub fn insert<E>(&mut self, oid: Oid<'a>, entry: E) -> Option<OidEntry> in insert()
173 self.map.insert(oid, entry.into()) in insert()
176 /// Returns a reference to the registry entry, if found for this OID.
177 pub fn get(&self, oid: &Oid<'a>) -> Option<&OidEntry> { in get()
178 self.map.get(oid) in get()
181 /// Return an Iterator over references to the OID numbers (registry keys)
182 pub fn keys(&self) -> impl Iterator<Item = &Oid<'a>> { in keys()
191 /// Return an Iterator over references to the `(Oid, OidEntry)` key/value pairs
192 pub fn iter(&self) -> impl Iterator<Item = (&Oid<'a>, &OidEntry)> { in iter()
196 /// Return the `(Oid, OidEntry)` key/value pairs, matching a short name
209 /// for (oid, entry) in registry.iter_by_sn("shortName") {
215 /// if let Some((oid, entry)) = opt_sn {
219 … pub fn iter_by_sn<S: Into<String>>(&self, sn: S) -> impl Iterator<Item = (&Oid<'a>, &OidEntry)> { in iter_by_sn()
240 /// Format a OID to a `String`, using the provided registry to get the short name if present.
241 pub fn format_oid(oid: &Oid, registry: &OidRegistry) -> String { in format_oid() argument
242 if let Some(entry) = registry.map.get(oid) { in format_oid()
243 format!("{} ({})", entry.sn, oid) in format_oid()
245 format!("{}", oid) in format_oid()
251 #[rustfmt::skip::macros(oid)]
259 fn add_entry(input: &str, oid: Oid<'static>, registry: &mut OidRegistry) { in test_lifetimes()
263 registry.insert(oid, entry); in test_lifetimes()
267 add_entry("a", oid!(1.2.3.4), &mut registry); in test_lifetimes()
268 add_entry("b", oid!(1.2.3.5), &mut registry); in test_lifetimes()
272 registry.insert(oid!(1.2.4.1), e); in test_lifetimes()
274 registry.insert(oid!(1.2.5.1), ("a", "b")); in test_lifetimes()