[][src]Struct bcder::Tag

pub struct Tag(_);

The tag of a BER encoded value.

Each BER encoded value starts with a sequence of one or more octets called the identifier octets. They encode both the tag of the value as well as whether the value uses primitive or constructed encoding. The Tag type represents the tag only. The distinction between primitive and constructed encoding is captured by the decoder types Primitive and Constructed instead.

The tag in turn consists of two parts: the class and the number – the Tag type includes both of them.

Limitations

We can only decode up to four identifier octets. That is, we only support tag numbers between 0 and 1fffff.

Implementations

impl Tag[src]

pub const END_OF_VALUE: Self[src]

The tag marking the end-of-value in an indefinite length value.

This is UNIVERSAL 0.

pub const BOOLEAN: Self[src]

The tag for the BOOLEAN type, UNIVERSAL 1.

pub const INTEGER: Self[src]

The tag for the INTEGER type, UNIVERSAL 2.

pub const BIT_STRING: Self[src]

The tag for the BIT STRING type, UNIVERSAL 3.

pub const OCTET_STRING: Self[src]

The tag for the OCTET STRING type, UNIVERSAL 4.

pub const NULL: Self[src]

The tag for the NULL type, UNIVERSAL 5.

pub const OID: Self[src]

The tag for the OBJECT IDENTIFIER type, UNIVERSAL 6.

pub const OBJECT_DESCRIPTOR: Self[src]

The tag for the ObjectDescriptor type, UNIVERSAL 7.

pub const EXTERNAL: Self[src]

The tag for the EXTERNAL and Instance-of types, UNIVERSAL 8.

pub const REAL: Self[src]

The tag for the REAL type, UNIVERSAL 9.

pub const ENUMERATED: Self[src]

The tag for the ENUMERATED type, UNIVERAL 10.

pub const EMBEDDED_PDV: Self[src]

The tag for the EMBEDDED PDV type, UNIVERAL 11.

pub const UTF8_STRING: Self[src]

The tag for the UTF8String type, UNIVERSAL 12

pub const RELATIVE_OID: Self[src]

The tag for the RELATIVE-OID type, UNIVERAL 13.

pub const SEQUENCE: Self[src]

The tag for the SEQUENCE and SEQUENCE OF types, UNIVERSAL 16.

pub const SET: Self[src]

The tag for the SET and SET OF types, UNIVERSAL 17.

pub const NUMERIC_STRING: Self[src]

The tag for the NumericString type, UNIVERSAL 18.

pub const PRINTABLE_STRING: Self[src]

The tag for the PrintableString type, UNIVERSAL 19.

pub const TELETEX_STRING: Self[src]

The tag for the TeletexString type, UNIVERSAL 20.

pub const VIDEOTEX_STRING: Self[src]

The tag for the VideotexString type, UNIVERSAL 21.

pub const IA5_STRING: Self[src]

The tag for the IA5String type, UNIVERSAL 22.

pub const UTC_TIME: Self[src]

The tag for the UTCTime type, UNIVERSAL 23.

pub const GENERALIZED_TIME: Self[src]

The tag for the GeneralizedType type, UNIVERAL 24.

pub const GRAPHIC_STRING: Self[src]

The tag for the GraphicString type, UNIVERSAL 25.

pub const VISIBLE_STRING: Self[src]

The tag for the VisibleString type, UNIVERSAL 26.

pub const GENERAL_STRING: Self[src]

The tag for the GeneralString type, UNIVERSAL 27.

pub const UNIVERSAL_STRING: Self[src]

The tag for the UniversalString type, UNIVERSAL 28.

pub const BMP_STRING: Self[src]

The tag for the BMPString type, UNIVERSAL 29.

pub const CTX_0: Self[src]

The tag context specific tag [0].

pub const CTX_1: Self[src]

The tag context specific tag [1].

pub const CTX_2: Self[src]

The tag context specific tag [2].

pub const CTX_3: Self[src]

The tag context specific tag [3].

pub const CTX_4: Self[src]

The tag context specific tag [4].

pub const CTX_5: Self[src]

The tag context specific tag [5].

pub const CTX_6: Self[src]

The tag context specific tag [6].

impl Tag[src]

pub fn universal(number: u32) -> Self[src]

Creates a new tag in the universal class with the given tag number.

Panics

Currently, this function panics if the tag number is greater than MAX_VAL_SPAN_3_OCTETS.

pub fn application(number: u32) -> Self[src]

Creates a new tag in the application class with the given tag number.

Panics

Currently, this function panics if the tag number is greater than MAX_VAL_SPAN_3_OCTETS.

pub fn ctx(number: u32) -> Self[src]

Creates a new tag in the context specific class.

Panics

Currently, this function panics if the provided tag number is greater than MAX_VAL_SPAN_3_OCTETS.

pub fn private(number: u32) -> Self[src]

Creates a new tag in the private class with the given tag number.

Panics

Currently, this function panics if the provided tag number is greater than MAX_VAL_SPAN_3_OCTETS.

pub fn is_universal(self) -> bool[src]

Returns whether the tag is of the universal class.

pub fn is_application(self) -> bool[src]

Returns whether the tag is of the application class.

pub fn is_context_specific(self) -> bool[src]

Returns whether the tag is of the context specific class.

pub fn is_private(self) -> bool[src]

Returns whether the tag is of the private class.

pub fn number(self) -> u32[src]

Returns the number of the tag.

pub fn take_from<S: Source>(source: &mut S) -> Result<(Self, bool), S::Err>[src]

Takes a tag from the beginning of a source.

Upon success, returns both the tag and whether the value is constructed. If there are no more octets available in the source, an error is returned.

pub fn take_from_if<S: Source>(
    self,
    source: &mut S
) -> Result<Option<bool>, S::Err>
[src]

Takes a tag from the beginning of a resource if it matches this tag.

If there is no more data available in the source or if the tag is something else, returns Ok(None). If the tag matches self, returns whether the value is constructed.

pub fn encoded_len(&self) -> usize[src]

Returns the number of octets of the encoded form of the tag.

pub fn write_encoded<W: Write>(
    &self,
    constructed: bool,
    target: &mut W
) -> Result<(), Error>
[src]

Encodes the tag into a target.

If constructed is true, the encoded tag will signal a value in constructed encoding and primitive encoding otherwise.

Trait Implementations

impl Clone for Tag[src]

impl Copy for Tag[src]

impl Debug for Tag[src]

impl Display for Tag[src]

impl Eq for Tag[src]

impl PartialEq<Tag> for Tag[src]

impl StructuralEq for Tag[src]

impl StructuralPartialEq for Tag[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.