TaggedParser

Struct TaggedParser 

pub struct TaggedParser<'a, TagKind, T, E = Error> {
    pub header: Header<'a>,
    pub inner: T,
    /* private fields */
}
Available on crate feature crypto only.

Fields§

§header: Header<'a>§inner: T

Implementations§

§

impl<'a, T, E> TaggedParser<'a, Explicit, T, E>

pub const fn new_explicit( class: Class, tag: u32, inner: T, ) -> TaggedParser<'a, Explicit, T, E>

pub fn from_ber_and_then<F>( class: Class, tag: u32, bytes: &'a [u8], op: F, ) -> Result<(&'a [u8], T), Err<E>>
where F: FnOnce(&'a [u8]) -> Result<(&'a [u8], T), Err<E>>, E: From<Error>,

Parse a BER tagged value and apply the provided parsing function to content

After parsing, the sequence object and header are discarded.

Note: this function is provided for Explicit, but there is not difference between explicit or implicit tags. The op function is responsible of handling the content.

pub fn from_der_and_then<F>( class: Class, tag: u32, bytes: &'a [u8], op: F, ) -> Result<(&'a [u8], T), Err<E>>
where F: FnOnce(&'a [u8]) -> Result<(&'a [u8], T), Err<E>>, E: From<Error>,

Parse a DER tagged value and apply the provided parsing function to content

After parsing, the sequence object and header are discarded.

Note: this function is provided for Explicit, but there is not difference between explicit or implicit tags. The op function is responsible of handling the content.

§

impl<T, E> TaggedParser<'_, Implicit, T, E>

pub const fn new_implicit( class: Class, constructed: bool, tag: u32, inner: T, ) -> TaggedParser<'_, Implicit, T, E>

§

impl<'a, TagKind, T, E> TaggedParser<'a, TagKind, T, E>

pub const fn new( header: Header<'a>, inner: T, ) -> TaggedParser<'a, TagKind, T, E>

pub const fn assert_class(&self, class: Class) -> Result<(), Error>

pub const fn assert_tag(&self, tag: Tag) -> Result<(), Error>

pub const fn class(&self) -> Class

pub const fn tag(&self) -> Tag

§

impl<'a, TagKind, T, E> TaggedParser<'a, TagKind, T, E>
where TaggedParser<'a, TagKind, T, E>: FromBer<'a, E>, E: From<Error>,

pub fn parse_ber( class: Class, tag: Tag, bytes: &'a [u8], ) -> Result<(&'a [u8], TaggedParser<'a, TagKind, T, E>), Err<E>>

§

impl<'a, TagKind, T, E> TaggedParser<'a, TagKind, T, E>
where TaggedParser<'a, TagKind, T, E>: FromDer<'a, E>, E: From<Error>,

pub fn parse_der( class: Class, tag: Tag, bytes: &'a [u8], ) -> Result<(&'a [u8], TaggedParser<'a, TagKind, T, E>), Err<E>>

Trait Implementations§

§

impl<TagKind, T, E> AsRef<T> for TaggedParser<'_, TagKind, T, E>

§

fn as_ref(&self) -> &T

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

impl<T> CheckDerConstraints for TaggedParser<'_, Explicit, T>

§

impl<T> CheckDerConstraints for TaggedParser<'_, Implicit, T>

§

impl<'a, TagKind, T, E> Debug for TaggedParser<'a, TagKind, T, E>
where TagKind: Debug, T: Debug, E: Debug,

§

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

Formats the value using the given formatter. Read more
§

impl<TagKind, T, E> DynTagged for TaggedParser<'_, TagKind, T, E>

§

fn tag(&self) -> Tag

§

impl<'a, T, E> FromBer<'a, E> for TaggedParser<'a, Explicit, T, E>
where T: FromBer<'a, E>, E: From<Error>,

§

fn from_ber( bytes: &'a [u8], ) -> Result<(&'a [u8], TaggedParser<'a, Explicit, T, E>), Err<E>>

Attempt to parse input bytes into a BER object
§

impl<'a, T, E> FromBer<'a, E> for TaggedParser<'a, Implicit, T, E>
where T: TryFrom<Any<'a>, Error = E> + Tagged, E: From<Error>,

§

fn from_ber( bytes: &'a [u8], ) -> Result<(&'a [u8], TaggedParser<'a, Implicit, T, E>), Err<E>>

Attempt to parse input bytes into a BER object
§

impl<'a, T, E> FromDer<'a, E> for TaggedParser<'a, Explicit, T, E>
where T: FromDer<'a, E>, E: From<Error>,

§

fn from_der( bytes: &'a [u8], ) -> Result<(&'a [u8], TaggedParser<'a, Explicit, T, E>), Err<E>>

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

impl<'a, T, E> FromDer<'a, E> for TaggedParser<'a, Implicit, T, E>
where T: TryFrom<Any<'a>, Error = E> + CheckDerConstraints + Tagged, E: From<Error>,

§

fn from_der( bytes: &'a [u8], ) -> Result<(&'a [u8], TaggedParser<'a, Implicit, T, E>), Err<E>>

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

impl<'a, TagKind, T, E> PartialEq for TaggedParser<'a, TagKind, T, E>
where TagKind: PartialEq, T: PartialEq, E: PartialEq,

§

fn eq(&self, other: &TaggedParser<'a, TagKind, T, E>) -> 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.
§

impl<T> ToDer for TaggedParser<'_, Explicit, T>
where T: ToDer,

Available on crate feature std only.
§

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

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

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

Attempt to write the DER header to this writer.
§

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

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

fn to_der_vec(&self) -> Result<Vec<u8>, SerializeError>

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

fn to_der_vec_raw(&self) -> Result<Vec<u8>, SerializeError>

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

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

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

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

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

impl<T> ToDer for TaggedParser<'_, Implicit, T>
where T: ToDer,

Available on crate feature std only.
§

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

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

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

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

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

Attempt to write the DER header to this writer.
§

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

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

fn to_der_vec(&self) -> Result<Vec<u8>, SerializeError>

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

fn to_der_vec_raw(&self) -> Result<Vec<u8>, SerializeError>

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

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

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

impl<'a, TagKind, T, E> Eq for TaggedParser<'a, TagKind, T, E>
where TagKind: Eq, T: Eq, E: Eq,

§

impl<'a, TagKind, T, E> StructuralPartialEq for TaggedParser<'a, TagKind, T, E>

Auto Trait Implementations§

§

impl<'a, TagKind, T, E> Freeze for TaggedParser<'a, TagKind, T, E>
where T: Freeze,

§

impl<'a, TagKind, T, E> RefUnwindSafe for TaggedParser<'a, TagKind, T, E>
where T: RefUnwindSafe, TagKind: RefUnwindSafe, E: RefUnwindSafe,

§

impl<'a, TagKind, T, E> Send for TaggedParser<'a, TagKind, T, E>
where T: Send, TagKind: Send, E: Send,

§

impl<'a, TagKind, T, E> Sync for TaggedParser<'a, TagKind, T, E>
where T: Sync, TagKind: Sync, E: Sync,

§

impl<'a, TagKind, T, E> Unpin for TaggedParser<'a, TagKind, T, E>
where T: Unpin, TagKind: Unpin, E: Unpin,

§

impl<'a, TagKind, T, E> UnwindSafe for TaggedParser<'a, TagKind, T, E>
where T: UnwindSafe, 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
§

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

§

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

§

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

§

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> RamaFrom<T> for U
where U: From<T>,

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryFrom<T> for U
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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