Type Alias rocket::mtls::oid::asn1_rs::OptTaggedExplicit

source ·
pub type OptTaggedExplicit<T, E, const TAG: u32> = Option<TaggedValue<T, E, Explicit, asn1_rs::::asn1_types::tagged::explicit::TaggedExplicit::{constant#0}, TAG>>;
Available on crate feature mtls only.
Expand description

A helper object to parse [ n ] EXPLICIT T OPTIONAL

A helper object implementing FromBer and FromDer, to parse tagged optional values.

This helper expects context-specific tags. Use Option< TaggedValue > for a more generic implementation.

§Examples

To parse a [0] EXPLICIT INTEGER OPTIONAL object:

use asn1_rs::{Error, FromBer, Integer, OptTaggedExplicit, TaggedValue};

let bytes = &[0xa0, 0x03, 0x2, 0x1, 0x2];

// If tagged object is present (and has expected tag), parsing succeeds:
let (_, tagged) = OptTaggedExplicit::<Integer, Error, 0>::from_ber(bytes).unwrap();
assert_eq!(tagged, Some(TaggedValue::explicit(Integer::from(2))));

// If tagged object is not present or has different tag, parsing
// also succeeds (returning None):
let (_, tagged) = OptTaggedExplicit::<Integer, Error, 0>::from_ber(&[]).unwrap();
assert_eq!(tagged, None);
let (_, tagged) = OptTaggedExplicit::<Integer, Error, 1>::from_ber(bytes).unwrap();
assert_eq!(tagged, None);

Aliased Type§

enum OptTaggedExplicit<T, E, const TAG: u32> {
    None,
    Some(TaggedValue<T, E, Explicit, 2, TAG>),
}

Variants§

§1.0.0

None

No value.

§1.0.0

Some(TaggedValue<T, E, Explicit, 2, TAG>)

Some value of type T.