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>
impl<TagKind, E> TaggedParserBuilder<TagKind, E>
sourcepub const fn with_class(self, class: Class) -> Self
pub const fn with_class(self, class: Class) -> Self
Set the expected Class
for the builder
source§impl<E> TaggedParserBuilder<Explicit, E>
impl<E> TaggedParserBuilder<Explicit, E>
source§impl<E> TaggedParserBuilder<Implicit, E>
impl<E> TaggedParserBuilder<Implicit, E>
source§impl<TagKind, E> TaggedParserBuilder<TagKind, E>
impl<TagKind, E> TaggedParserBuilder<TagKind, E>
sourcepub fn ber_parser<'a, T>(
self,
) -> impl Fn(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, TagKind, T, E>, E>
pub fn ber_parser<'a, T>( self, ) -> impl Fn(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, TagKind, T, E>, E>
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>
impl<TagKind, E> TaggedParserBuilder<TagKind, E>
sourcepub fn der_parser<'a, T>(
self,
) -> impl Fn(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, TagKind, T, E>, E>
pub fn der_parser<'a, T>( self, ) -> impl Fn(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, TagKind, T, E>, E>
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>
impl<TagKind: Clone, E: Clone> Clone for TaggedParserBuilder<TagKind, E>
source§fn clone(&self) -> TaggedParserBuilder<TagKind, E>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreimpl<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>
impl<TagKind, E> Sync for TaggedParserBuilder<TagKind, E>
impl<TagKind, E> Unpin for TaggedParserBuilder<TagKind, E>
impl<TagKind, E> UnwindSafe for TaggedParserBuilder<TagKind, E>where
TagKind: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)