Struct const_oid::ObjectIdentifier [−][src]
Object identifier (OID).
OIDs are hierarchical structures consisting of “arcs”, i.e. integer identifiers.
Implementations
impl ObjectIdentifier
[src]
pub const fn new(arcs: &[Arc]) -> Self
[src]
Create an ObjectIdentifier
from a slice of integers, where each
integer represents an “arc” (a.k.a. node) in the OID.
NOTE: this method is soft-deprecated and will be removed in a future
release. We recommend using ObjectIdentifier::parse
going forward
(which will be renamed to ObjectIdentifier::new
in a future release).
Panics
To enable const fn
usage and work around current limitations thereof,
this method panics in the event the OID is malformed.
For that reason this method is not recommended except for use in
constants (where it will generate a compiler error instead).
To parse an OID from a &[Arc]
slice without panicking on error,
use TryFrom<&[Arc]>
instead.
In order for an OID to be valid, 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 the
MAX_LEN
constant
pub const fn parse(s: &str) -> Self
[src]
Parse an ObjectIdentifier
from the dot-delimited string form, e.g.:
use const_oid::ObjectIdentifier; const MY_OID: ObjectIdentifier = ObjectIdentifier::parse("1.2.840.113549.1.1.1");
Like ObjectIdentifier::new
, this version is intended for use in
const
contexts. where it will generate compile errors in the event
the OID is malformed.
This method is NOT intended for use outside of const contexts, as it
will panic with a bad error message. However, this type also has a
FromStr
impl that can be used for fallible parsing.
pub fn as_bytes(&self) -> &[u8]
[src]
Get the BER/DER serialization of this OID as bytes
pub fn arc(&self, index: usize) -> Option<Arc>
[src]
Return the arc with the given index, if it exists.
pub fn arcs(&self) -> Arcs<'_>ⓘ
[src]
Iterate over the arcs (a.k.a. nodes) in an ObjectIdentifier
.
Returns Arcs
, an iterator over Arc
values representing the value
of each arc/node.
pub fn len(&self) -> usize
[src]
Number of arcs in this ObjectIdentifier
.
pub fn from_ber(ber_bytes: &[u8]) -> Result<Self>
[src]
Parse an OID from from its BER/DER encoding.
pub fn ber_len(&self) -> usize
[src]
Please use the as_bytes()
function instead
Get the length of this OID when serialized as ASN.1 BER.
pub fn write_ber<'a>(&self, bytes: &'a mut [u8]) -> Result<&'a [u8]>
[src]
Please use the as_bytes()
function instead
Write the BER encoding of this OID into the given slice, returning a new slice containing the written data.
pub fn to_ber(&self) -> Vec<u8>
[src]
Please use the as_bytes()
function instead
alloc
only.Serialize this OID as ASN.1 BER.
Trait Implementations
impl AsRef<[u8]> for ObjectIdentifier
[src]
impl Clone for ObjectIdentifier
[src]
fn clone(&self) -> ObjectIdentifier
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ObjectIdentifier
[src]
impl Debug for ObjectIdentifier
[src]
impl Display for ObjectIdentifier
[src]
impl Eq for ObjectIdentifier
[src]
impl From<&'_ ObjectIdentifier> for ObjectIdentifier
[src]
fn from(oid: &ObjectIdentifier) -> ObjectIdentifier
[src]
impl FromStr for ObjectIdentifier
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(string: &str) -> Result<Self>
[src]
impl PartialEq<ObjectIdentifier> for ObjectIdentifier
[src]
fn eq(&self, other: &ObjectIdentifier) -> bool
[src]
fn ne(&self, other: &ObjectIdentifier) -> bool
[src]
impl StructuralEq for ObjectIdentifier
[src]
impl StructuralPartialEq for ObjectIdentifier
[src]
impl TryFrom<&'_ [u32]> for ObjectIdentifier
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,