Type Alias asn1_rs::OptTaggedImplicit

source ·
pub type OptTaggedImplicit<T, E, const TAG: u32> = Option<TaggedImplicit<T, E, TAG>>;
Expand description

A helper object to parse [ n ] IMPLICIT 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] IMPLICIT INTEGER OPTIONAL object:

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

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

let (_, tagged) = OptTaggedImplicit::<Integer, Error, 0>::from_ber(bytes).unwrap();
assert_eq!(tagged, Some(TaggedValue::implicit(Integer::from(2))));

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

Aliased Type§

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

Variants§

§1.0.0

None

No value.

§1.0.0

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

Some value of type T.