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<'_>
pub const fn new(asn1: Cow<'a, [u8]>) -> Oid<'_>
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<'_>
pub const fn new_relative(asn1: Cow<'a, [u8]>) -> Oid<'_>
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 FusedIterator<Item = u64> + ExactSizeIterator + '_>
pub fn iter( &self, ) -> Option<impl FusedIterator<Item = u64> + 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]) -> ParseResult<'a, Self>
pub fn from_der_relative(bytes: &'a [u8]) -> ParseResult<'a, Self>
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 for Oid<'a>
impl<'a> PartialEq for Oid<'a>
source§impl ToDer for Oid<'_>
impl ToDer for Oid<'_>
source§fn to_der_len(&self) -> Result<usize>
fn to_der_len(&self) -> Result<usize>
source§fn write_der_header(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der_header(&self, writer: &mut dyn Write) -> SerializeResult<usize>
source§fn write_der_content(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der_content(&self, writer: &mut dyn Write) -> SerializeResult<usize>
source§fn to_der_vec(&self) -> SerializeResult<Vec<u8>>
fn to_der_vec(&self) -> SerializeResult<Vec<u8>>
Vec<u8>
.source§fn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>
fn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>
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) -> SerializeResult<usize>
fn write_der(&self, writer: &mut dyn Write) -> SerializeResult<usize>
source§fn write_der_raw(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der_raw(&self, writer: &mut dyn Write) -> SerializeResult<usize>
to_der
, but uses provided values without changes.
This can generate an invalid encoding for a DER object.impl DerAutoDerive for Oid<'_>
impl<'a> Eq for Oid<'a>
impl<'a> StructuralPartialEq for Oid<'a>
Auto Trait Implementations§
impl<'a> Freeze for Oid<'a>
impl<'a> RefUnwindSafe for Oid<'a>
impl<'a> Send for Oid<'a>
impl<'a> Sync for Oid<'a>
impl<'a> Unpin for Oid<'a>
impl<'a> UnwindSafe for Oid<'a>
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)