Skip to main content

Asn1Value

Struct Asn1Value 

Source
pub struct Asn1Value { /* private fields */ }
Expand description

Owned DER value + builder. Constructs canonical X.690 DER programmatically for reference and testing. alloc-gated — the pipeline binds the borrowed Asn1Carrier handle, which needs no allocator. There is no width or element-count ceiling.

Implementations§

Source§

impl Asn1Value

Source

pub fn parse(raw: &[u8]) -> Result<Self, ShapeViolation>

Validate a DER byte sequence and retain an owned copy.

§Errors

Surfaces the [ShapeViolation] validate_der would raise.

Source

pub fn boolean(value: bool) -> Self

Build a Boolean (DER tag 0x01).

Source

pub fn null() -> Self

Build a Null (DER tag 0x05).

Source

pub fn integer(value: i64) -> Self

Build an Integer (DER tag 0x02) from a signed 64-bit value. DER §8.3: minimum-octets two’s-complement big-endian.

Source

pub fn octet_string(bytes: &[u8]) -> Self

Build an OctetString (DER tag 0x04) from raw bytes.

Source

pub fn sequence(children: &[Asn1Value]) -> Self

Build a Sequence (DER tag 0x30).

Source

pub fn set(children: &[Asn1Value]) -> Self

Build a Set (DER tag 0x31). DER (X.690 §11.6) requires Set element ordering by ascending encoded-element byte sequence.

Source

pub fn bit_string(bits: &[u8], unused_bits: u8) -> Result<Self, ShapeViolation>

Build a BIT STRING (DER tag 0x03). X.690 §8.6 / §11.2.

§Errors

[INVALID_DER_VIOLATION] for invalid unused-bit counts or non-zero trailing bits.

Source

pub fn object_identifier(arcs: &[u32]) -> Result<Self, ShapeViolation>

Build an OBJECT IDENTIFIER (DER tag 0x06). X.690 §8.19.

§Errors

[INVALID_DER_VIOLATION] for fewer than two arcs or out-of-range leading arcs.

Source

pub fn utf8_string(s: &str) -> Self

Build a UTF8String (DER tag 0x0C).

Source

pub fn printable_string(s: &str) -> Result<Self, ShapeViolation>

Build a PrintableString (DER tag 0x13). X.680 §41.4 character set.

§Errors

[INVALID_DER_VIOLATION] for characters outside the PrintableString set.

Source

pub fn ia5_string(s: &str) -> Result<Self, ShapeViolation>

Build an IA5String (DER tag 0x16). X.680 §41.2.

§Errors

[INVALID_DER_VIOLATION] for non-ASCII input.

Source

pub fn tagged_bytes(&self) -> &[u8]

Borrow the DER-encoded canonical bytes.

Trait Implementations§

Source§

impl Clone for Asn1Value

Source§

fn clone(&self) -> Asn1Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Asn1Value

Available on crate feature alloc only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Asn1Value

Source§

fn eq(&self, other: &Asn1Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Asn1Value

Source§

impl StructuralPartialEq for Asn1Value

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.