logo
pub struct TaggedParserBuilder<TagKind> { /* private fields */ }
Available on crate feature mtls only.
Expand description

A builder for parsing tagged values (IMPLICIT or EXPLICIT)

Examples

use asn1_rs::{Class, Tag, TaggedParserBuilder};

let parser = TaggedParserBuilder::explicit()
    .with_class(Class::ContextSpecific)
    .with_tag(Tag(0))
    .der_parser::<u32>();

let input = &[0xa0, 0x03, 0x02, 0x01, 0x02];
let (rem, tagged) = parser(input).expect("parsing failed");

assert!(rem.is_empty());
assert_eq!(tagged.tag(), Tag(0));
assert_eq!(tagged.as_ref(), &2);

Implementations

Create a default TaggedParserBuilder builder

TagKind must be specified as either Explicit or Implicit

use asn1_rs::{Explicit, TaggedParserBuilder};

let builder = TaggedParserBuilder::<Explicit>::new();

Set the expected Class for the builder

Set the expected Tag for the builder

Create a TagParser builder for EXPLICIT tagged values

Create a TagParser builder for IMPLICIT tagged values

Create the BER parser from the builder parameters

This method will consume the builder and return a parser (to be used as a function).

Create the DER parser from the builder parameters

This method will consume the builder and return a parser (to be used as a function).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Converts self into a collection.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more