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
sourceimpl<'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<'b>(s: &'b [u64]) -> Result<Oid<'static>, OidParseError>
pub fn from<'b>(s: &'b [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<'b>(s: &'b [u64]) -> Result<Oid<'static>, OidParseError>
pub fn from_relative<'b>(s: &'b [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 as_bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Get the encoded oid without the header.
sourcepub fn bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
👎 Deprecated since 0.2.0: Use as_bytes
instead
pub fn bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Use as_bytes
instead
Get 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]) -> 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
sourceimpl<'a> CheckDerConstraints for Oid<'a>
impl<'a> CheckDerConstraints for Oid<'a>
fn check_constraints(any: &Any<'_>) -> Result<()>
sourceimpl ToDer for Oid<'_>
impl ToDer for Oid<'_>
sourcefn to_der_len(&self) -> Result<usize>
fn to_der_len(&self) -> Result<usize>
Get the length of the object, when encoded Read more
sourcefn write_der_header(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der_header(&self, writer: &mut dyn Write) -> SerializeResult<usize>
Attempt to write the DER header to this writer.
sourcefn write_der_content(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der_content(&self, writer: &mut dyn Write) -> SerializeResult<usize>
Attempt to write the DER content (all except header) to this writer.
sourcefn to_der_vec(&self) -> SerializeResult<Vec<u8>>
fn to_der_vec(&self) -> SerializeResult<Vec<u8>>
Write the DER encoded representation to a newly allocated Vec<u8>
.
sourcefn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>
fn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>
Similar to using to_vec
, but uses provided values without changes.
This can generate an invalid encoding for a DER object. Read more
sourcefn write_der(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der(&self, writer: &mut dyn Write) -> SerializeResult<usize>
Attempt to write the DER encoded representation (header and content) into this writer. Read more
sourcefn write_der_raw(&self, writer: &mut dyn Write) -> SerializeResult<usize>
fn write_der_raw(&self, writer: &mut dyn Write) -> SerializeResult<usize>
Similar to using to_der
, but uses provided values without changes.
This can generate an invalid encoding for a DER object. Read more
impl DerAutoDerive for Oid<'_>
impl<'a> Eq for Oid<'a>
impl<'a> StructuralEq for Oid<'a>
impl<'a> StructuralPartialEq for Oid<'a>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more