Struct pkcs8::ObjectIdentifier
source · [−]pub struct ObjectIdentifier { /* private fields */ }
Expand description
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_len
]
Implementations
sourceimpl ObjectIdentifier
impl ObjectIdentifier
sourcepub const MAX_LENGTH: usize = 23usize
pub const MAX_LENGTH: usize = 23usize
Maximum length of a BER/DER-encoded OID in bytes.
sourcepub const fn new(s: &str) -> ObjectIdentifier
pub const fn new(s: &str) -> ObjectIdentifier
Parse an ObjectIdentifier
from the dot-delimited string form, e.g.:
use const_oid::ObjectIdentifier;
pub const MY_OID: ObjectIdentifier = ObjectIdentifier::new("1.2.840.113549.1.1.1");
Panics
This method panics in the event the OID is malformed according to the “Validity” rules given in the toplevel documentation for this type.
For that reason this method is ONLY recommended for use in constants (where it will generate a compiler error instead).
To parse an OID from a &str
slice fallibly and without panicking,
use the FromStr
impl instead (or via str
’s parse
method).
sourcepub fn from_arcs(arcs: &[u32]) -> Result<ObjectIdentifier, Error>
pub fn from_arcs(arcs: &[u32]) -> Result<ObjectIdentifier, Error>
Parse an OID from a slice of Arc
values (i.e. integers).
sourcepub fn from_bytes(ber_bytes: &[u8]) -> Result<ObjectIdentifier, Error>
pub fn from_bytes(ber_bytes: &[u8]) -> Result<ObjectIdentifier, Error>
Parse an OID from from its BER/DER encoding.
sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Get the BER/DER serialization of this OID as bytes.
Note that this encoding omits the tag/length, and only contains the value portion of the encoded OID.
sourcepub fn arc(&self, index: usize) -> Option<u32>
pub fn arc(&self, index: usize) -> Option<u32>
Return the arc with the given index, if it exists.
sourcepub fn arcs(&self) -> Arcs<'_>
pub fn arcs(&self) -> Arcs<'_>
Iterate over the arcs (a.k.a. nodes) of an ObjectIdentifier
.
Returns Arcs
, an iterator over Arc
values representing the value
of each arc/node.
Trait Implementations
sourceimpl AsRef<[u8]> for ObjectIdentifier
impl AsRef<[u8]> for ObjectIdentifier
sourceimpl Clone for ObjectIdentifier
impl Clone for ObjectIdentifier
sourcefn clone(&self) -> ObjectIdentifier
fn clone(&self) -> ObjectIdentifier
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ObjectIdentifier
impl Debug for ObjectIdentifier
sourceimpl Display for ObjectIdentifier
impl Display for ObjectIdentifier
sourceimpl Encodable for ObjectIdentifier
impl Encodable for ObjectIdentifier
sourcefn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this value in bytes when encoded as ASN.1 DER.
sourcefn encode(&self, encoder: &mut Encoder<'_>) -> Result<(), Error>
fn encode(&self, encoder: &mut Encoder<'_>) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided Encoder
.
sourcefn encode_to_slice(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
fn encode_to_slice(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
Encode this value to the provided byte slice, returning a sub-slice containing the encoded message. Read more
sourceimpl<'_> From<&ObjectIdentifier> for ObjectIdentifier
impl<'_> From<&ObjectIdentifier> for ObjectIdentifier
sourcefn from(oid: &ObjectIdentifier) -> ObjectIdentifier
fn from(oid: &ObjectIdentifier) -> ObjectIdentifier
Converts to this type from the input type.
sourceimpl FromStr for ObjectIdentifier
impl FromStr for ObjectIdentifier
sourceimpl Hash for ObjectIdentifier
impl Hash for ObjectIdentifier
sourceimpl Ord for ObjectIdentifier
impl Ord for ObjectIdentifier
sourceimpl PartialEq<ObjectIdentifier> for ObjectIdentifier
impl PartialEq<ObjectIdentifier> for ObjectIdentifier
sourcefn eq(&self, other: &ObjectIdentifier) -> bool
fn eq(&self, other: &ObjectIdentifier) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ObjectIdentifier) -> bool
fn ne(&self, other: &ObjectIdentifier) -> bool
This method tests for !=
.
sourceimpl PartialOrd<ObjectIdentifier> for ObjectIdentifier
impl PartialOrd<ObjectIdentifier> for ObjectIdentifier
sourcefn partial_cmp(&self, other: &ObjectIdentifier) -> Option<Ordering>
fn partial_cmp(&self, other: &ObjectIdentifier) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'_> TryFrom<&[u8]> for ObjectIdentifier
impl<'_> TryFrom<&[u8]> for ObjectIdentifier
sourceimpl<'_> TryFrom<Any<'_>> for ObjectIdentifier
impl<'_> TryFrom<Any<'_>> for ObjectIdentifier
impl Copy for ObjectIdentifier
impl Eq for ObjectIdentifier
impl StructuralEq for ObjectIdentifier
impl StructuralPartialEq for ObjectIdentifier
Auto Trait Implementations
impl RefUnwindSafe for ObjectIdentifier
impl Send for ObjectIdentifier
impl Sync for ObjectIdentifier
impl Unpin for ObjectIdentifier
impl UnwindSafe for ObjectIdentifier
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
sourceimpl<'a, T> Choice<'a> for T where
T: Decodable<'a> + Encodable + Tagged,
impl<'a, T> Choice<'a> for T where
T: Decodable<'a> + Encodable + Tagged,
sourcefn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Is the provided Tag
decodable as a variant of this CHOICE
?