Struct asn1_rs::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 copy 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: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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

§

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

§

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.