Struct coins_bip32::ecdsa::signature::digest::const_oid::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_SIZE
Implementations§
source§impl ObjectIdentifier
impl ObjectIdentifier
sourcepub const fn new_unwrap(s: &str) -> ObjectIdentifier
pub const fn new_unwrap(s: &str) -> ObjectIdentifier
Parse an ObjectIdentifier
from the dot-delimited string form,
panicking on parse errors.
This function exists as a workaround for unwrap
not yet being
stable in const fn
contexts, and is intended to allow the result to
be bound to a constant value:
use const_oid::ObjectIdentifier;
pub const MY_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1");
In future versions of Rust it should be possible to replace this with
ObjectIdentifier::new(...).unwrap()
.
Use ObjectIdentifier::new
for fallible parsing.
sourcepub const fn new(s: &str) -> Result<ObjectIdentifier, Error>
pub const fn new(s: &str) -> Result<ObjectIdentifier, Error>
Parse an ObjectIdentifier
from the dot-delimited string form.
sourcepub fn from_arcs(
arcs: impl IntoIterator<Item = u32>,
) -> Result<ObjectIdentifier, Error>
pub fn from_arcs( arcs: impl IntoIterator<Item = 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
.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of this ObjectIdentifier
in arcs.
sourcepub fn parent(&self) -> Option<ObjectIdentifier>
pub fn parent(&self) -> Option<ObjectIdentifier>
Get the parent OID of this one (if applicable).
Trait Implementations§
source§impl AsRef<[u8]> for ObjectIdentifier
impl AsRef<[u8]> for ObjectIdentifier
source§impl Clone for ObjectIdentifier
impl Clone for ObjectIdentifier
source§fn clone(&self) -> ObjectIdentifier
fn clone(&self) -> ObjectIdentifier
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ObjectIdentifier
impl Debug for ObjectIdentifier
source§impl<'a> DecodeValue<'a> for ObjectIdentifier
impl<'a> DecodeValue<'a> for ObjectIdentifier
source§fn decode_value<R>(
reader: &mut R,
header: Header,
) -> Result<ObjectIdentifier, Error>where
R: Reader<'a>,
fn decode_value<R>(
reader: &mut R,
header: Header,
) -> Result<ObjectIdentifier, Error>where
R: Reader<'a>,
Reader
.source§impl Display for ObjectIdentifier
impl Display for ObjectIdentifier
source§impl EncodeValue for ObjectIdentifier
impl EncodeValue for ObjectIdentifier
source§impl From<&ObjectIdentifier> for ObjectIdentifier
impl From<&ObjectIdentifier> for ObjectIdentifier
source§fn from(oid: &ObjectIdentifier) -> ObjectIdentifier
fn from(oid: &ObjectIdentifier) -> ObjectIdentifier
source§impl FromStr for ObjectIdentifier
impl FromStr for ObjectIdentifier
source§impl Hash for ObjectIdentifier
impl Hash for ObjectIdentifier
source§impl Ord for ObjectIdentifier
impl Ord for ObjectIdentifier
source§fn cmp(&self, other: &ObjectIdentifier) -> Ordering
fn cmp(&self, other: &ObjectIdentifier) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ObjectIdentifier
impl PartialEq for ObjectIdentifier
source§fn eq(&self, other: &ObjectIdentifier) -> bool
fn eq(&self, other: &ObjectIdentifier) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ObjectIdentifier
impl PartialOrd for ObjectIdentifier
source§fn partial_cmp(&self, other: &ObjectIdentifier) -> Option<Ordering>
fn partial_cmp(&self, other: &ObjectIdentifier) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<&[u8]> for ObjectIdentifier
impl TryFrom<&[u8]> for ObjectIdentifier
source§impl TryFrom<AnyRef<'_>> for ObjectIdentifier
impl TryFrom<AnyRef<'_>> for ObjectIdentifier
impl Copy for ObjectIdentifier
impl Eq for ObjectIdentifier
impl StructuralPartialEq for ObjectIdentifier
Auto Trait Implementations§
impl Freeze for ObjectIdentifier
impl RefUnwindSafe for ObjectIdentifier
impl Send for ObjectIdentifier
impl Sync for ObjectIdentifier
impl Unpin for ObjectIdentifier
impl UnwindSafe for ObjectIdentifier
Blanket Implementations§
source§impl<T> Base32Len for T
impl<T> Base32Len for T
source§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
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> CheckBase32<Vec<u5>> for T
impl<T> CheckBase32<Vec<u5>> for 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
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
source§impl<T> Encode for Twhere
T: EncodeValue + Tagged,
impl<T> Encode for Twhere
T: EncodeValue + Tagged,
source§fn 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.
source§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided Writer
.
source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
source§impl<T> ToBase32 for T
impl<T> ToBase32 for T
source§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Lower case letters are used (e.g. f9b4ca
).source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Upper case letters are used (e.g. F9B4CA
).source§impl<T> ToHexExt for T
impl<T> ToHexExt for T
source§fn encode_hex(&self) -> String
fn encode_hex(&self) -> String
self
into the result.
Lower case letters are used (e.g. f9b4ca
).source§fn encode_hex_upper(&self) -> String
fn encode_hex_upper(&self) -> String
self
into the result.
Upper case letters are used (e.g. F9B4CA
).source§fn encode_hex_with_prefix(&self) -> String
fn encode_hex_with_prefix(&self) -> String
self
into the result with prefix 0x
.
Lower case letters are used (e.g. 0xf9b4ca
).source§fn encode_hex_upper_with_prefix(&self) -> String
fn encode_hex_upper_with_prefix(&self) -> String
self
into the result with prefix 0X
.
Upper case letters are used (e.g. 0xF9B4CA
).