⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

AsnBuilder

Struct AsnBuilder 

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

Fluent builder for constructing ASN.1 values.

§Example

let data = AsnBuilder::new()
    .sequence(|s| {
        s.integer(42)
         .octet_string(b"hello")
         .boolean(true)
    })
    .build();

Implementations§

Source§

impl AsnBuilder

Source

pub fn new() -> Self

Create a new empty builder.

Source

pub fn boolean(self, value: bool) -> Self

Add a BOOLEAN value.

Source

pub fn integer(self, value: i64) -> Self

Add an INTEGER value.

Source

pub fn big_integer(self, bytes: &[u8]) -> Self

Add a BigInteger value (raw bytes, two’s complement).

Source

pub fn bit_string(self, data: &[u8], unused_bits: u8) -> Self

Add a BIT STRING value.

Source

pub fn octet_string(self, data: &[u8]) -> Self

Add an OCTET STRING value.

Source

pub fn null(self) -> Self

Add a NULL value.

Source

pub fn oid(self, arcs: &[u32]) -> Self

Add an OBJECT IDENTIFIER value.

Source

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

Add a UTF8String value.

Source

pub fn enumerated(self, value: i64) -> Self

Add an ENUMERATED value.

Source

pub fn context_specific(self, number: u8, data: &[u8]) -> Self

Add a context-specific tagged value.

Source

pub fn context_specific_value(self, number: u8, value: &AsnValue) -> Self

Add a context-specific tagged value wrapping an encoded ASN.1 value.

Source

pub fn sequence<F>(self, f: F) -> Self
where F: FnOnce(AsnBuilder) -> AsnBuilder,

Add a nested SEQUENCE built with a closure.

Source

pub fn set<F>(self, f: F) -> Self
where F: FnOnce(AsnBuilder) -> AsnBuilder,

Add a nested SET built with a closure.

Source

pub fn value(self, v: AsnValue) -> Self

Add a raw pre-built AsnValue.

Source

pub fn build(self) -> Vec<u8>

Build the accumulated items.

If there is exactly one item, returns its encoded form. If there are multiple items, wraps them in a SEQUENCE.

Source

pub fn build_value(self) -> AsnValue

Build and return the items as an AsnValue::Sequence.

Trait Implementations§

Source§

impl Default for AsnBuilder

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for AsnBuilder

§

impl RefUnwindSafe for AsnBuilder

§

impl Send for AsnBuilder

§

impl Sync for AsnBuilder

§

impl Unpin for AsnBuilder

§

impl UnwindSafe for AsnBuilder

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.