Object Identifiers are a standard of the ITU used to reference objects, things, and
concepts in a globally unique way. This crate provides for data structures and methods
to build, parse, and format OIDs.
Parsing OID String Representation
use oid::prelude::*;
fn main() -> Result<(), ObjectIdentifierError> {
let oid = ObjectIdentifier::try_from("0.1.2.3")?;
Ok(())
}
Parsing OID Binary Representation
use oid::prelude::*;
fn main() -> Result<(), ObjectIdentifierError> {
let oid = ObjectIdentifier::try_from(vec![0x00, 0x01, 0x02, 0x03])?;
Ok(())
}
Encoding OID as String Representation
use oid::prelude::*;
fn main() -> Result<(), ObjectIdentifierError> {
let oid = ObjectIdentifier::try_from("0.1.2.3")?;
let oid: String = oid.into();
assert_eq!(oid, "0.1.2.3");
Ok(())
}
Encoding OID as Binary Representation
use oid::prelude::*;
fn main() -> Result<(), ObjectIdentifierError> {
let oid = ObjectIdentifier::try_from(vec![0x00, 0x01, 0x02, 0x03])?;
let oid: Vec<u8> = oid.into();
assert_eq!(oid, vec![0x00, 0x01, 0x02, 0x03]);
Ok(())
}