asn1_rs

Type Alias PrivateExplicit

Source
pub type PrivateExplicit<T, E, const TAG: u32> = TaggedValue<T, E, Explicit, { Class::PRIVATE }, TAG>;
Expand description

A helper object to parse [PRIVATE n] EXPLICIT T

A helper object implementing FromBer and FromDer, to parse explicit private-tagged values.

§Examples

To parse a [PRIVATE 0] EXPLICIT INTEGER object:

use asn1_rs::{Error, FromBer, Integer, PrivateExplicit, TaggedValue};

let bytes = &[0xe0, 0x03, 0x2, 0x1, 0x2];

// If tagged object is present (and has expected tag), parsing succeeds:
let (_, tagged) = PrivateExplicit::<Integer, Error, 0>::from_ber(bytes).unwrap();
assert_eq!(tagged, TaggedValue::explicit(Integer::from(2)));

Aliased Type§

struct PrivateExplicit<T, E, const TAG: u32> { /* private fields */ }

Implementations

Source§

impl<T, E, const CLASS: u8, const TAG: u32> TaggedValue<T, E, Explicit, CLASS, TAG>

Source

pub const fn explicit(inner: T) -> Self

Constructs a new EXPLICIT TaggedParser with the provided value

Source§

impl<T, E, TagKind, const CLASS: u8, const TAG: u32> TaggedValue<T, E, TagKind, CLASS, TAG>

Source

pub fn into_inner(self) -> T

Consumes the TaggedParser, returning the wrapped value.

Source

pub const fn tag(&self) -> Tag

Return the (outer) tag of this object

Source

pub const fn class(&self) -> u8

Return the (outer) class of this object

Trait Implementations

Source§

impl<T, E, TagKind, const CLASS: u8, const TAG: u32> AsRef<T> for TaggedValue<T, E, TagKind, CLASS, TAG>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, E, const CLASS: u8, const TAG: u32> CheckDerConstraints for TaggedValue<T, E, Explicit, CLASS, TAG>

Source§

impl<T: Debug, E: Debug, TagKind: Debug, const CLASS: u8, const TAG: u32> Debug for TaggedValue<T, E, TagKind, CLASS, TAG>

Source§

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

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

impl<'a, T, E, const CLASS: u8, const TAG: u32> FromDer<'a, E> for TaggedValue<T, E, Explicit, CLASS, TAG>
where T: FromDer<'a, E>, E: From<Error>,

Source§

fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self, E>

Attempt to parse input bytes into a DER object (enforcing constraints)
Source§

impl<T: PartialEq, E: PartialEq, TagKind: PartialEq, const CLASS: u8, const TAG: u32> PartialEq for TaggedValue<T, E, TagKind, CLASS, TAG>

Source§

fn eq(&self, other: &TaggedValue<T, E, TagKind, CLASS, TAG>) -> 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<T, E, TagKind, const CLASS: u8, const TAG: u32> Tagged for TaggedValue<T, E, TagKind, CLASS, TAG>

Source§

impl<T, E, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, E, Explicit, CLASS, TAG>
where T: ToDer,

Source§

fn to_der_len(&self) -> Result<usize>

Get the length of the object (including the header), when encoded
Source§

fn write_der_header(&self, writer: &mut dyn Write) -> SerializeResult<usize>

Attempt to write the DER header to this writer.
Source§

fn write_der_content(&self, writer: &mut dyn Write) -> SerializeResult<usize>

Attempt to write the DER content (all except header) to this writer.
Source§

fn to_der_vec(&self) -> SerializeResult<Vec<u8>>

Write the DER encoded representation to a newly allocated Vec<u8>.
Source§

fn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>

Similar to using to_vec, but uses provided values without changes. This can generate an invalid encoding for a DER object.
Source§

fn write_der(&self, writer: &mut dyn Write) -> SerializeResult<usize>

Attempt to write the DER encoded representation (header and content) into this writer. Read more
Source§

fn write_der_raw(&self, writer: &mut dyn Write) -> SerializeResult<usize>

Similar to using to_der, but uses provided values without changes. This can generate an invalid encoding for a DER object.
Source§

impl<'a, 'b, T, E, const CLASS: u8, const TAG: u32> TryFrom<&'b Any<'a>> for TaggedValue<T, E, Explicit, CLASS, TAG>
where T: FromBer<'a, E>, E: From<Error>,

Source§

type Error = E

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

fn try_from(any: &'b Any<'a>) -> Result<Self, E>

Performs the conversion.
Source§

impl<'a, T, E, const CLASS: u8, const TAG: u32> TryFrom<Any<'a>> for TaggedValue<T, E, Explicit, CLASS, TAG>
where T: FromBer<'a, E>, E: From<Error>,

Source§

type Error = E

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

fn try_from(any: Any<'a>) -> Result<Self, E>

Performs the conversion.
Source§

impl<T: Eq, E: Eq, TagKind: Eq, const CLASS: u8, const TAG: u32> Eq for TaggedValue<T, E, TagKind, CLASS, TAG>

Source§

impl<T, E, TagKind, const CLASS: u8, const TAG: u32> StructuralPartialEq for TaggedValue<T, E, TagKind, CLASS, TAG>