Struct ObjectIdentifier
pub struct ObjectIdentifier<const MAX_SIZE: usize = DEFAULT_MAX_SIZE> { /* private fields */ }
Object identifier (OID).
OIDs are hierarchical structures consisting of "arcs", i.e. integer identifiers.
Validity
In order for an OID to be considered valid by this library, it must meet the following criteria:
- The OID MUST have at least 3 arcs
- The first arc MUST be within the range 0-2
- The second arc MUST be within the range 0-39
- The BER/DER encoding of the OID MUST be shorter than
ObjectIdentifier::MAX_SIZE
Implementations
impl ObjectIdentifier
const MAX_SIZE: usize = DEFAULT_MAX_SIZE;Maximum size of a BER/DER-encoded OID in bytes.
const fn new_unwrap(s: &str) -> SelfParse an
ObjectIdentifierfrom the dot-delimited string form, panicking on parse errors.This function exists as a workaround for
unwrapnot yet being stable inconst fncontexts, and is intended to allow the result to be bound to a constant value:use ObjectIdentifier; pub const MY_OID: ObjectIdentifier = new_unwrap;In future versions of Rust it should be possible to replace this with
ObjectIdentifier::new(...).unwrap().Use
ObjectIdentifier::newfor fallible parsing.const fn new(s: &str) -> Result<Self>Parse an
ObjectIdentifierfrom the dot-delimited string form.fn from_arcs(arcs: impl IntoIterator<Item = Arc>) -> Result<Self>Parse an OID from a slice of
Arcvalues (i.e. integers).fn from_bytes(ber_bytes: &[u8]) -> Result<Self>Parse an OID from from its BER/DER encoding.
impl<const MAX_SIZE: usize> ObjectIdentifier<MAX_SIZE>
fn from_bytes_sized(ber_bytes: &[u8]) -> Result<Self>Parse an OID from from its BER/DER encoding.
Returns
Err(Error::Length)if bytes do not fit inMAX_SIZE.const fn as_bytes(&self) -> &[u8]Get the BER/DER serialization of this OID as bytes.
Note that this encoding omits the ASN.1 tag/length, and only contains the value portion of the encoded OID.
const fn as_oid_ref(&self) -> &ObjectIdentifierRefBorrow an
ObjectIdentifierRefwhich corresponds to thisObjectIdentifier.fn parent(&self) -> Option<Self>Get the parent OID of this one (if applicable).
const fn push_arc(self, arc: Arc) -> Result<Self>Push an additional arc onto this OID, returning the child OID.
const fn starts_with<const SIZE: usize>(&self, other: ObjectIdentifier<SIZE>) -> boolDoes this OID start with the other OID?
Trait Implementations
impl FromStr for ObjectIdentifier
type Err = Error;fn from_str(string: &str) -> Result<Self>
impl TryFrom<&[u8]> for ObjectIdentifier
type Error = Error;fn try_from(ber_bytes: &[u8]) -> Result<Self>
impl<const MAX_SIZE: usize> AsRef<ObjectIdentifierRef> for ObjectIdentifier<MAX_SIZE>
fn as_ref(&self) -> &ObjectIdentifierRef
impl<const MAX_SIZE: usize> AsRef<[u8]> for ObjectIdentifier<MAX_SIZE>
fn as_ref(&self) -> &[u8]
impl<const MAX_SIZE: usize> Borrow<ObjectIdentifierRef> for ObjectIdentifier<MAX_SIZE>
fn borrow(&self) -> &ObjectIdentifierRef
impl<const MAX_SIZE: usize> Clone for ObjectIdentifier<MAX_SIZE>
fn clone(&self) -> ObjectIdentifier<MAX_SIZE>
impl<const MAX_SIZE: usize> Copy for ObjectIdentifier<MAX_SIZE>
impl<const MAX_SIZE: usize> Debug for ObjectIdentifier<MAX_SIZE>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<const MAX_SIZE: usize> Deref for ObjectIdentifier<MAX_SIZE>
type Target = ObjectIdentifierRef;fn deref(&self) -> &ObjectIdentifierRef
impl<const MAX_SIZE: usize> Display for ObjectIdentifier<MAX_SIZE>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<const MAX_SIZE: usize> Eq for ObjectIdentifier<MAX_SIZE>
impl<const MAX_SIZE: usize> Hash for ObjectIdentifier<MAX_SIZE>
fn hash<__H: Hasher>(&self, state: &mut __H)
impl<const MAX_SIZE: usize> Ord for ObjectIdentifier<MAX_SIZE>
fn cmp(&self, other: &ObjectIdentifier<MAX_SIZE>) -> Ordering
impl<const MAX_SIZE: usize> PartialEq for ObjectIdentifier<MAX_SIZE>
fn eq(&self, other: &ObjectIdentifier<MAX_SIZE>) -> bool
impl<const MAX_SIZE: usize> PartialOrd for ObjectIdentifier<MAX_SIZE>
fn partial_cmp(&self, other: &ObjectIdentifier<MAX_SIZE>) -> Option<Ordering>
impl<const MAX_SIZE: usize> StructuralPartialEq for ObjectIdentifier<MAX_SIZE>
impl<const MAX_SIZE: usize> TryFrom<&ObjectIdentifierRef> for ObjectIdentifier<MAX_SIZE>
type Error = Error;fn try_from(oid_ref: &ObjectIdentifierRef) -> Result<Self>
Auto Trait Implementations
impl<const MAX_SIZE: usize> Freeze for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: Freeze,
impl<const MAX_SIZE: usize> RefUnwindSafe for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: RefUnwindSafe,
impl<const MAX_SIZE: usize> Send for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: Send,
impl<const MAX_SIZE: usize> Sync for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: Sync,
impl<const MAX_SIZE: usize> Unpin for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: Unpin,
impl<const MAX_SIZE: usize> UnsafeUnpin for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: UnsafeUnpin,
impl<const MAX_SIZE: usize> UnwindSafe for ObjectIdentifier<MAX_SIZE>
where
Buffer<MAX_SIZE>: UnwindSafe,
Blanket Implementations
impl<P, T> Receiver for ObjectIdentifier<MAX_SIZE>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for ObjectIdentifier<MAX_SIZE>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ObjectIdentifier<MAX_SIZE>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ObjectIdentifier<MAX_SIZE>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ObjectIdentifier<MAX_SIZE>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ObjectIdentifier<MAX_SIZE>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for ObjectIdentifier<MAX_SIZE>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ObjectIdentifier<MAX_SIZE>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for ObjectIdentifier<MAX_SIZE>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>