Struct bcder::Tag

source ·
pub struct Tag(/* private fields */);
Expand description

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§

source§

impl Tag

source

pub const END_OF_VALUE: Self = _

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

This is UNIVERSAL 0.

source

pub const BOOLEAN: Self = _

The tag for the BOOLEAN type, UNIVERSAL 1.

source

pub const INTEGER: Self = _

The tag for the INTEGER type, UNIVERSAL 2.

source

pub const BIT_STRING: Self = _

The tag for the BIT STRING type, UNIVERSAL 3.

source

pub const OCTET_STRING: Self = _

The tag for the OCTET STRING type, UNIVERSAL 4.

source

pub const NULL: Self = _

The tag for the NULL type, UNIVERSAL 5.

source

pub const OID: Self = _

The tag for the OBJECT IDENTIFIER type, UNIVERSAL 6.

source

pub const OBJECT_DESCRIPTOR: Self = _

The tag for the ObjectDescriptor type, UNIVERSAL 7.

source

pub const EXTERNAL: Self = _

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

source

pub const REAL: Self = _

The tag for the REAL type, UNIVERSAL 9.

source

pub const ENUMERATED: Self = _

The tag for the ENUMERATED type, UNIVERSAL 10.

source

pub const EMBEDDED_PDV: Self = _

The tag for the EMBEDDED PDV type, UNIVERSAL 11.

source

pub const UTF8_STRING: Self = _

The tag for the UTF8String type, UNIVERSAL 12

source

pub const RELATIVE_OID: Self = _

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

source

pub const TIME: Self = _

The tag for the TIME type, UNIVERSAL 14.

source

pub const SEQUENCE: Self = _

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

source

pub const SET: Self = _

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

source

pub const NUMERIC_STRING: Self = _

The tag for the NumericString type, UNIVERSAL 18.

source

pub const PRINTABLE_STRING: Self = _

The tag for the PrintableString type, UNIVERSAL 19.

source

pub const TELETEX_STRING: Self = _

The tag for the TeletexString type, UNIVERSAL 20.

source

pub const VIDEOTEX_STRING: Self = _

The tag for the VideotexString type, UNIVERSAL 21.

source

pub const IA5_STRING: Self = _

The tag for the IA5String type, UNIVERSAL 22.

source

pub const UTC_TIME: Self = _

The tag for the UTCTime type, UNIVERSAL 23.

source

pub const GENERALIZED_TIME: Self = _

The tag for the GeneralizedType type, UNIVERSAL 24.

source

pub const GRAPHIC_STRING: Self = _

The tag for the GraphicString type, UNIVERSAL 25.

source

pub const VISIBLE_STRING: Self = _

The tag for the VisibleString type, UNIVERSAL 26.

source

pub const GENERAL_STRING: Self = _

The tag for the GeneralString type, UNIVERSAL 27.

source

pub const UNIVERSAL_STRING: Self = _

The tag for the UniversalString type, UNIVERSAL 28.

source

pub const CHARACTER_STRING: Self = _

The tag for the CHARACTER STRING type, UNIVERSAL 29.

source

pub const BMP_STRING: Self = _

The tag for the BMPString type, UNIVERSAL 30.

source

pub const DATE: Self = _

The tag for the DATE type, UNIVERSAL 31.

source

pub const TIME_OF_DAY: Self = _

The tag for the TIME-OF-DAY type, UNIVERSAL 32.

source

pub const DATE_TIME: Self = _

The tag for the DATE-TIME type, UNIVERSAL 33.

source

pub const DURATION: Self = _

The tag for the DURATION type, UNIVERSAL 34.

source

pub const OID_IRI: Self = _

The tag for the OID-IRI type, UNIVERSAL 35.

source

pub const RELATIVE_OID_IRI: Self = _

The tag for the RELATIVE-OID-IRI type, UNIVERSAL 36.

source

pub const CTX_0: Self = _

The tag context specific tag [0].

source

pub const CTX_1: Self = _

The tag context specific tag [1].

source

pub const CTX_2: Self = _

The tag context specific tag [2].

source

pub const CTX_3: Self = _

The tag context specific tag [3].

source

pub const CTX_4: Self = _

The tag context specific tag [4].

source

pub const CTX_5: Self = _

The tag context specific tag [5].

source

pub const CTX_6: Self = _

The tag context specific tag [6].

source§

impl Tag

source

pub fn universal(number: u32) -> Self

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.

source

pub fn application(number: u32) -> Self

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.

source

pub fn ctx(number: u32) -> Self

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.

source

pub fn private(number: u32) -> Self

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.

source

pub fn is_universal(self) -> bool

Returns whether the tag is of the universal class.

source

pub fn is_application(self) -> bool

Returns whether the tag is of the application class.

source

pub fn is_context_specific(self) -> bool

Returns whether the tag is of the context specific class.

source

pub fn is_private(self) -> bool

Returns whether the tag is of the private class.

source

pub fn number(self) -> u32

Returns the number of the tag.

source

pub fn take_opt_from<S: Source>( source: &mut S ) -> Result<Option<(Self, bool)>, DecodeError<S::Error>>

Takes an optional tag from the beginning of a source.

Upon success, returns both the tag and whether the value is constructed.

source

pub fn take_from<S: Source>( source: &mut S ) -> Result<(Self, bool), DecodeError<S::Error>>

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.

source

pub fn take_from_if<S: Source>( self, source: &mut S ) -> Result<Option<bool>, DecodeError<S::Error>>

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.

source

pub fn encoded_len(&self) -> usize

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

source

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

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§

source§

impl Clone for Tag

source§

fn clone(&self) -> Tag

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Tag

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for Tag

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq for Tag

source§

fn eq(&self, other: &Tag) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Tag

source§

impl Eq for Tag

source§

impl StructuralEq for Tag

source§

impl StructuralPartialEq for Tag

Auto Trait Implementations§

§

impl RefUnwindSafe for Tag

§

impl Send for Tag

§

impl Sync for Tag

§

impl Unpin for Tag

§

impl UnwindSafe for Tag

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
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
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.