TaggedParserBuilder

Struct TaggedParserBuilder 

Source
pub struct TaggedParserBuilder<TagKind, E = Error> { /* private fields */ }
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§

Source§

impl<TagKind, E> TaggedParserBuilder<TagKind, E>

Source

pub const fn new() -> Self

Create a default TaggedParserBuilder builder

TagKind must be specified as either Explicit or Implicit

use asn1_rs::{Explicit, TaggedParserBuilder};

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

pub const fn with_class(self, class: Class) -> Self

Set the expected Class for the builder

Source

pub const fn with_tag(self, tag: Tag) -> Self

Set the expected Tag for the builder

Source§

impl<E> TaggedParserBuilder<Explicit, E>

Source

pub const fn explicit() -> Self

Create a TagParser builder for EXPLICIT tagged values

Source§

impl<E> TaggedParserBuilder<Implicit, E>

Source

pub const fn implicit() -> Self

Create a TagParser builder for IMPLICIT tagged values

Source§

impl<TagKind, E> TaggedParserBuilder<TagKind, E>

Source

pub fn ber_parser<'a, T>( self, ) -> impl Fn(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, TagKind, T, E>, E>
where TaggedParser<'a, TagKind, T, E>: FromBer<'a, E>, E: From<Error>,

Create the BER parser from the builder parameters

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

Source§

impl<TagKind, E> TaggedParserBuilder<TagKind, E>

Source

pub fn der_parser<'a, T>( self, ) -> impl Fn(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, TagKind, T, E>, E>
where TaggedParser<'a, TagKind, T, E>: FromDer<'a, E>, E: From<Error>,

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§

Source§

impl<TagKind: Clone, E: Clone> Clone for TaggedParserBuilder<TagKind, E>

Source§

fn clone(&self) -> TaggedParserBuilder<TagKind, E>

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<TagKind: Debug, E: Debug> Debug for TaggedParserBuilder<TagKind, E>

Source§

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

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

impl<TagKind, E> Default for TaggedParserBuilder<TagKind, E>

Source§

fn default() -> Self

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

impl<TagKind: Copy, E: Copy> Copy for TaggedParserBuilder<TagKind, E>

Auto Trait Implementations§

§

impl<TagKind, E> Freeze for TaggedParserBuilder<TagKind, E>

§

impl<TagKind, E> RefUnwindSafe for TaggedParserBuilder<TagKind, E>
where TagKind: RefUnwindSafe, E: RefUnwindSafe,

§

impl<TagKind, E> Send for TaggedParserBuilder<TagKind, E>
where TagKind: Send, E: Send,

§

impl<TagKind, E> Sync for TaggedParserBuilder<TagKind, E>
where TagKind: Sync, E: Sync,

§

impl<TagKind, E> Unpin for TaggedParserBuilder<TagKind, E>
where TagKind: Unpin, E: Unpin,

§

impl<TagKind, E> UnwindSafe for TaggedParserBuilder<TagKind, E>
where TagKind: UnwindSafe, E: UnwindSafe,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> 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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes