Struct TaggedValue
pub struct TaggedValue<T, E, TagKind, const CLASS: u8, const TAG: u32> { /* private fields */ }Available on crate feature
crypto only.Expand description
Helper object for creating FromBer/FromDer types for TAGGED OPTIONAL types
When parsing ContextSpecific (the most common class), see TaggedExplicit and
TaggedImplicit alias types.
§Notes
CLASS must be between 0 and 4. See Class for possible values for the CLASS parameter.
Constants from this class can be used, but they must be wrapped in braces due to
Rust syntax for generics
(see example below).
§Examples
To parse a [APPLICATION 0] EXPLICIT INTEGER object:
use asn1_rs::{Class, Error, Explicit, FromBer, Integer, TaggedValue};
let bytes = &[0x60, 0x03, 0x2, 0x1, 0x2];
// If tagged object is present (and has expected tag), parsing succeeds:
let (_, tagged) =
TaggedValue::<Integer, Error, Explicit, {Class::APPLICATION}, 0>::from_ber(bytes)
.unwrap();
assert_eq!(tagged, TaggedValue::explicit(Integer::from(2)));Implementations§
§impl<T, E, TagKind, const CLASS: u8, const TAG: u32> TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> TaggedValue<T, E, TagKind, CLASS, TAG>
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the TaggedParser, returning the wrapped value.
§impl<T, E, const CLASS: u8, const TAG: u32> TaggedValue<T, E, Explicit, CLASS, TAG>
impl<T, E, const CLASS: u8, const TAG: u32> TaggedValue<T, E, Explicit, CLASS, TAG>
pub const fn explicit(inner: T) -> TaggedValue<T, E, Explicit, CLASS, TAG>
pub const fn explicit(inner: T) -> TaggedValue<T, E, Explicit, CLASS, TAG>
Constructs a new EXPLICIT TaggedParser with the provided value
§impl<T, E, const CLASS: u8, const TAG: u32> TaggedValue<T, E, Implicit, CLASS, TAG>
impl<T, E, const CLASS: u8, const TAG: u32> TaggedValue<T, E, Implicit, CLASS, TAG>
pub const fn implicit(inner: T) -> TaggedValue<T, E, Implicit, CLASS, TAG>
pub const fn implicit(inner: T) -> TaggedValue<T, E, Implicit, CLASS, TAG>
Constructs a new IMPLICIT TaggedParser with the provided value
Trait Implementations§
§impl<T, E, TagKind, const CLASS: u8, const TAG: u32> AsRef<T> for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> AsRef<T> for TaggedValue<T, E, TagKind, CLASS, TAG>
§impl<T, E, const CLASS: u8, const TAG: u32> CheckDerConstraints for TaggedValue<T, E, Explicit, CLASS, TAG>where
T: CheckDerConstraints,
impl<T, E, const CLASS: u8, const TAG: u32> CheckDerConstraints for TaggedValue<T, E, Explicit, CLASS, TAG>where
T: CheckDerConstraints,
§impl<T, E, const CLASS: u8, const TAG: u32> CheckDerConstraints for TaggedValue<T, E, Implicit, CLASS, TAG>where
T: CheckDerConstraints + Tagged,
impl<T, E, const CLASS: u8, const TAG: u32> CheckDerConstraints for TaggedValue<T, E, Implicit, CLASS, TAG>where
T: CheckDerConstraints + Tagged,
§impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Debug for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Debug for TaggedValue<T, E, TagKind, CLASS, TAG>
§impl<'a, T, E, const CLASS: u8, const TAG: u32> FromDer<'a, E> for TaggedValue<T, E, Explicit, CLASS, TAG>
impl<'a, T, E, const CLASS: u8, const TAG: u32> FromDer<'a, E> for TaggedValue<T, E, Explicit, CLASS, TAG>
§impl<'a, T, E, const CLASS: u8, const TAG: u32> FromDer<'a, E> for TaggedValue<T, E, Implicit, CLASS, TAG>
impl<'a, T, E, const CLASS: u8, const TAG: u32> FromDer<'a, E> for TaggedValue<T, E, Implicit, CLASS, TAG>
§impl<T, E, TagKind, const CLASS: u8, const TAG: u32> PartialEq for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> PartialEq for TaggedValue<T, E, TagKind, CLASS, TAG>
§fn eq(&self, other: &TaggedValue<T, E, TagKind, CLASS, TAG>) -> bool
fn eq(&self, other: &TaggedValue<T, E, TagKind, CLASS, TAG>) -> bool
Tests for
self and other values to be equal, and is used by ==.§impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Tagged for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Tagged for TaggedValue<T, E, TagKind, CLASS, TAG>
§impl<T, E, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, E, Explicit, CLASS, TAG>where
T: ToDer,
Available on crate feature std only.
impl<T, E, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, E, Explicit, CLASS, TAG>where
T: ToDer,
Available on crate feature
std only.§fn to_der_len(&self) -> Result<usize, Error>
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>
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>
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>
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>
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>
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>
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, E, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, E, Implicit, CLASS, TAG>where
T: ToDer,
Available on crate feature std only.
impl<T, E, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, E, Implicit, CLASS, TAG>where
T: ToDer,
Available on crate feature
std only.§fn to_der_len(&self) -> Result<usize, Error>
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>
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>
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>
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>
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>
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>
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, 'b, T, E, const CLASS: u8, const TAG: u32> TryFrom<&'b Any<'a>> for TaggedValue<T, E, Explicit, CLASS, TAG>
impl<'a, 'b, T, E, const CLASS: u8, const TAG: u32> TryFrom<&'b Any<'a>> for TaggedValue<T, E, Explicit, CLASS, TAG>
§impl<'a, 'b, E, T, const CLASS: u8, const TAG: u32> TryFrom<&'b Any<'a>> for TaggedValue<T, E, Implicit, CLASS, TAG>
impl<'a, 'b, E, T, const CLASS: u8, const TAG: u32> TryFrom<&'b Any<'a>> for TaggedValue<T, E, Implicit, CLASS, TAG>
§impl<'a, T, E, const CLASS: u8, const TAG: u32> TryFrom<Any<'a>> for TaggedValue<T, E, Explicit, CLASS, TAG>
impl<'a, T, E, const CLASS: u8, const TAG: u32> TryFrom<Any<'a>> for TaggedValue<T, E, Explicit, CLASS, TAG>
§impl<'a, T, E, const CLASS: u8, const TAG: u32> TryFrom<Any<'a>> for TaggedValue<T, E, Implicit, CLASS, TAG>
impl<'a, T, E, const CLASS: u8, const TAG: u32> TryFrom<Any<'a>> for TaggedValue<T, E, Implicit, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Eq for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> StructuralPartialEq for TaggedValue<T, E, TagKind, CLASS, TAG>
Auto Trait Implementations§
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Freeze for TaggedValue<T, E, TagKind, CLASS, TAG>where
T: Freeze,
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> RefUnwindSafe for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Send for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Sync for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> Unpin for TaggedValue<T, E, TagKind, CLASS, TAG>
impl<T, E, TagKind, const CLASS: u8, const TAG: u32> UnwindSafe for TaggedValue<T, E, TagKind, CLASS, TAG>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
§impl<T> Choice for Twhere
T: Tagged,
impl<T> Choice for Twhere
T: Tagged,
§fn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Is the provided
Tag decodable as a variant of this CHOICE?§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Create a new
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more