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
impl Asn1Value
Sourcepub fn parse(raw: &[u8]) -> Result<Self, ShapeViolation>
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.
Sourcepub fn integer(value: i64) -> Self
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.
Sourcepub fn octet_string(bytes: &[u8]) -> Self
pub fn octet_string(bytes: &[u8]) -> Self
Build an OctetString (DER tag 0x04) from raw bytes.
Sourcepub fn set(children: &[Asn1Value]) -> Self
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.
Sourcepub fn bit_string(bits: &[u8], unused_bits: u8) -> Result<Self, ShapeViolation>
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.
Sourcepub fn object_identifier(arcs: &[u32]) -> Result<Self, ShapeViolation>
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.
Sourcepub fn utf8_string(s: &str) -> Self
pub fn utf8_string(s: &str) -> Self
Build a UTF8String (DER tag 0x0C).
Sourcepub fn printable_string(s: &str) -> Result<Self, ShapeViolation>
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.
Sourcepub fn ia5_string(s: &str) -> Result<Self, ShapeViolation>
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.
Sourcepub fn tagged_bytes(&self) -> &[u8] ⓘ
pub fn tagged_bytes(&self) -> &[u8] ⓘ
Borrow the DER-encoded canonical bytes.