Struct der_parser::Oid
source · pub struct Oid<'a> { /* private fields */ }
Expand description
Object ID (OID) representation which can be relative or non-relative.
An example for an OID in string representation is "1.2.840.113549.1.1.5"
.
For non-relative OIDs restrictions apply to the first two components.
This library contains a procedural macro oid
which can be used to
create oids. For example oid!(1.2.44.233)
or oid!(rel 44.233)
for relative oids. See the module documentation for more information.
Implementations§
source§impl<'a> Oid<'a>
impl<'a> Oid<'a>
sourcepub const fn new(asn1: Cow<'a, [u8]>) -> Oid<'a>
pub const fn new(asn1: Cow<'a, [u8]>) -> Oid<'a>
Create an OID from the ASN.1 DER encoded form. See the module documentation for other ways to create oids.
sourcepub const fn new_relative(asn1: Cow<'a, [u8]>) -> Oid<'a>
pub const fn new_relative(asn1: Cow<'a, [u8]>) -> Oid<'a>
Create a relative OID from the ASN.1 DER encoded form. See the module documentation for other ways to create relative oids.
sourcepub fn from(s: &[u64]) -> Result<Oid<'static>, OidParseError>
pub fn from(s: &[u64]) -> Result<Oid<'static>, OidParseError>
Build an OID from an array of object identifier components. This method allocates memory on the heap.
sourcepub fn from_relative(s: &[u64]) -> Result<Oid<'static>, OidParseError>
pub fn from_relative(s: &[u64]) -> Result<Oid<'static>, OidParseError>
Build a relative OID from an array of object identifier components.
sourcepub fn to_owned(&self) -> Oid<'static>
pub fn to_owned(&self) -> Oid<'static>
Create a deep copy of the oid.
This method allocates data on the heap. The returned oid can be used without keeping the ASN.1 representation around.
Cloning the returned oid does again allocate data.
sourcepub fn bytes(&self) -> &[u8] ⓘ
👎Deprecated since 0.2.0: Use as_bytes
instead
pub fn bytes(&self) -> &[u8] ⓘ
as_bytes
insteadGet the encoded oid without the header.
sourcepub fn to_id_string(&self) -> String
pub fn to_id_string(&self) -> String
Convert the OID to a string representation.
If every arc fits into a u64 a string like “1.2.840.113549.1.1.5” is returned, otherwise a hex representation.
See also the “bigint” feature of this crate.
sourcepub fn iter(
&self
) -> Option<impl Iterator<Item = u64> + FusedIterator + ExactSizeIterator>
pub fn iter( &self ) -> Option<impl Iterator<Item = u64> + FusedIterator + ExactSizeIterator>
Return an iterator over the sub-identifiers (arcs).
Returns None
if at least one arc does not fit into u64
.
pub fn from_ber_relative( bytes: &'a [u8] ) -> Result<(&'a [u8], Oid<'a>), Err<Error>>
pub fn from_der_relative( bytes: &'a [u8] ) -> Result<(&'a [u8], Oid<'a>), Err<Error>>
sourcepub fn starts_with(&self, needle: &Oid<'_>) -> bool
pub fn starts_with(&self, needle: &Oid<'_>) -> bool
Returns true if needle
is a prefix of the OID.
Trait Implementations§
source§impl<'a> CheckDerConstraints for Oid<'a>
impl<'a> CheckDerConstraints for Oid<'a>
source§impl<'a> PartialEq<Oid<'a>> for Oid<'a>
impl<'a> PartialEq<Oid<'a>> for Oid<'a>
source§impl ToDer for Oid<'_>
impl ToDer for Oid<'_>
source§fn to_der_len(&self) -> Result<usize, Error>
fn to_der_len(&self) -> Result<usize, Error>
source§fn write_der_header(
&self,
writer: &mut dyn Write
) -> Result<usize, SerializeError>
fn write_der_header( &self, writer: &mut dyn Write ) -> Result<usize, SerializeError>
source§fn write_der_content(
&self,
writer: &mut dyn Write
) -> Result<usize, SerializeError>
fn write_der_content( &self, writer: &mut dyn Write ) -> Result<usize, SerializeError>
source§fn to_der_vec(&self) -> Result<Vec<u8, Global>, SerializeError>
fn to_der_vec(&self) -> Result<Vec<u8, Global>, SerializeError>
Vec<u8>
.source§fn to_der_vec_raw(&self) -> Result<Vec<u8, Global>, SerializeError>
fn to_der_vec_raw(&self) -> Result<Vec<u8, Global>, SerializeError>
to_vec
, but uses provided values without changes.
This can generate an invalid encoding for a DER object.source§fn write_der(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>
fn write_der(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>
source§fn write_der_raw(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>
fn write_der_raw(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>
to_der
, but uses provided values without changes.
This can generate an invalid encoding for a DER object.