pub struct RelativeOid { /* private fields */ }Expand description
ASN.1 RELATIVE-OID
A RELATIVE-OID is a sequence of integer components (arcs) that identifies an object relative to some other OID. Unlike OBJECT IDENTIFIER, a RELATIVE-OID can have any number of components (including zero) and does not apply special encoding to the first two components.
Uses SmallVec to avoid allocations for most RELATIVE-OIDs (< 10 components)
Implementations§
Source§impl RelativeOid
impl RelativeOid
Sourcepub fn new(components: &[u32]) -> Self
pub fn new(components: &[u32]) -> Self
Create a new RelativeOid from a slice of component integers.
Unlike OBJECT IDENTIFIER, RELATIVE-OID has no validation constraints on the component values or count. An empty RELATIVE-OID is valid.
§Example
use synta::RelativeOid;
// Trust anchor ID suffix (e.g., "1" in "32473.1")
let roid = RelativeOid::new(&[1]);
assert_eq!(roid.to_string(), "1");
// Empty RELATIVE-OID is valid
let empty = RelativeOid::new(&[]);
assert_eq!(empty.to_string(), "");Sourcepub fn components(&self) -> &[u32]
pub fn components(&self) -> &[u32]
Return the RELATIVE-OID as a slice of component integers.
§Example
use synta::RelativeOid;
let roid = RelativeOid::new(&[1, 2, 3]);
assert!(matches!(roid.components(), [1, 2, 3]));Sourcepub fn from_content_bytes(data: &[u8]) -> Result<Self>
pub fn from_content_bytes(data: &[u8]) -> Result<Self>
Parse a RELATIVE-OID from its DER/BER content bytes — the raw value
bytes inside a RELATIVE-OID TLV, with the tag (0x0D) and length already
stripped.
§Errors
Returns Error::InvalidOid if data contains
a truncated base-128 sequence or causes a u32 overflow in any component.
§Example
use synta::RelativeOid;
// RELATIVE-OID with components [1, 2, 3]
let roid = RelativeOid::from_content_bytes(&[0x01, 0x02, 0x03]).unwrap();
assert_eq!(roid.to_string(), "1.2.3");Sourcepub fn to_content_bytes(&self) -> Vec<u8> ⓘ
pub fn to_content_bytes(&self) -> Vec<u8> ⓘ
Encode this RELATIVE-OID as DER content bytes — the raw base-128 arc
bytes without the 0x0D tag byte or the length field.
This is the symmetric counterpart to from_content_bytes.
§Example
use synta::RelativeOid;
let roid = RelativeOid::new(&[1, 2, 3]);
assert_eq!(roid.to_content_bytes(), &[0x01, 0x02, 0x03]);
// Round-trip
assert_eq!(RelativeOid::from_content_bytes(&roid.to_content_bytes()).unwrap(), roid);Trait Implementations§
Source§impl Clone for RelativeOid
impl Clone for RelativeOid
Source§fn clone(&self) -> RelativeOid
fn clone(&self) -> RelativeOid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelativeOid
impl Debug for RelativeOid
Source§impl Decode<'_> for RelativeOid
impl Decode<'_> for RelativeOid
Source§impl Display for RelativeOid
impl Display for RelativeOid
Source§impl Encode for RelativeOid
impl Encode for RelativeOid
impl Eq for RelativeOid
Source§impl FromStr for RelativeOid
Available on crate feature std only.
impl FromStr for RelativeOid
std only.Source§impl PartialEq for RelativeOid
impl PartialEq for RelativeOid
impl StructuralPartialEq for RelativeOid
Auto Trait Implementations§
impl Freeze for RelativeOid
impl RefUnwindSafe for RelativeOid
impl Send for RelativeOid
impl Sync for RelativeOid
impl Unpin for RelativeOid
impl UnsafeUnpin for RelativeOid
impl UnwindSafe for RelativeOid
Blanket Implementations§
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§impl<T> TagForOptional for Twhere
T: Tagged,
impl<T> TagForOptional for Twhere
T: Tagged,
Source§fn optional_tag() -> Option<Tag>
fn optional_tag() -> Option<Tag>
None if
the type accepts multiple tags (CHOICE) or any tag (ANY / Element<'a>).