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
impl Tag
sourcepub const END_OF_VALUE: Self = _
pub const END_OF_VALUE: Self = _
The tag marking the end-of-value in an indefinite length value.
This is UNIVERSAL 0.
sourcepub const BIT_STRING: Self = _
pub const BIT_STRING: Self = _
The tag for the BIT STRING type, UNIVERSAL 3.
sourcepub const OCTET_STRING: Self = _
pub const OCTET_STRING: Self = _
The tag for the OCTET STRING type, UNIVERSAL 4.
sourcepub const OBJECT_DESCRIPTOR: Self = _
pub const OBJECT_DESCRIPTOR: Self = _
The tag for the ObjectDescriptor type, UNIVERSAL 7.
sourcepub const ENUMERATED: Self = _
pub const ENUMERATED: Self = _
The tag for the ENUMERATED type, UNIVERSAL 10.
sourcepub const EMBEDDED_PDV: Self = _
pub const EMBEDDED_PDV: Self = _
The tag for the EMBEDDED PDV type, UNIVERSAL 11.
sourcepub const UTF8_STRING: Self = _
pub const UTF8_STRING: Self = _
The tag for the UTF8String type, UNIVERSAL 12
sourcepub const RELATIVE_OID: Self = _
pub const RELATIVE_OID: Self = _
The tag for the RELATIVE-OID type, UNIVERSAL 13.
sourcepub const NUMERIC_STRING: Self = _
pub const NUMERIC_STRING: Self = _
The tag for the NumericString type, UNIVERSAL 18.
sourcepub const PRINTABLE_STRING: Self = _
pub const PRINTABLE_STRING: Self = _
The tag for the PrintableString type, UNIVERSAL 19.
sourcepub const TELETEX_STRING: Self = _
pub const TELETEX_STRING: Self = _
The tag for the TeletexString type, UNIVERSAL 20.
sourcepub const VIDEOTEX_STRING: Self = _
pub const VIDEOTEX_STRING: Self = _
The tag for the VideotexString type, UNIVERSAL 21.
sourcepub const IA5_STRING: Self = _
pub const IA5_STRING: Self = _
The tag for the IA5String type, UNIVERSAL 22.
sourcepub const GENERALIZED_TIME: Self = _
pub const GENERALIZED_TIME: Self = _
The tag for the GeneralizedType type, UNIVERSAL 24.
sourcepub const GRAPHIC_STRING: Self = _
pub const GRAPHIC_STRING: Self = _
The tag for the GraphicString type, UNIVERSAL 25.
sourcepub const VISIBLE_STRING: Self = _
pub const VISIBLE_STRING: Self = _
The tag for the VisibleString type, UNIVERSAL 26.
sourcepub const GENERAL_STRING: Self = _
pub const GENERAL_STRING: Self = _
The tag for the GeneralString type, UNIVERSAL 27.
sourcepub const UNIVERSAL_STRING: Self = _
pub const UNIVERSAL_STRING: Self = _
The tag for the UniversalString type, UNIVERSAL 28.
sourcepub const CHARACTER_STRING: Self = _
pub const CHARACTER_STRING: Self = _
The tag for the CHARACTER STRING type, UNIVERSAL 29.
sourcepub const BMP_STRING: Self = _
pub const BMP_STRING: Self = _
The tag for the BMPString type, UNIVERSAL 30.
sourcepub const TIME_OF_DAY: Self = _
pub const TIME_OF_DAY: Self = _
The tag for the TIME-OF-DAY type, UNIVERSAL 32.
sourcepub const RELATIVE_OID_IRI: Self = _
pub const RELATIVE_OID_IRI: Self = _
The tag for the RELATIVE-OID-IRI type, UNIVERSAL 36.
source§impl Tag
impl Tag
sourcepub fn universal(number: u32) -> Self
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
.
sourcepub fn application(number: u32) -> Self
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
.
sourcepub fn ctx(number: u32) -> Self
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
.
sourcepub fn private(number: u32) -> Self
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
.
sourcepub fn is_universal(self) -> bool
pub fn is_universal(self) -> bool
Returns whether the tag is of the universal class.
sourcepub fn is_application(self) -> bool
pub fn is_application(self) -> bool
Returns whether the tag is of the application class.
sourcepub fn is_context_specific(self) -> bool
pub fn is_context_specific(self) -> bool
Returns whether the tag is of the context specific class.
sourcepub fn is_private(self) -> bool
pub fn is_private(self) -> bool
Returns whether the tag is of the private class.
sourcepub fn take_opt_from<S: Source>(
source: &mut S
) -> Result<Option<(Self, bool)>, DecodeError<S::Error>>
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.
sourcepub fn take_from<S: Source>(
source: &mut S
) -> Result<(Self, bool), DecodeError<S::Error>>
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.
sourcepub fn take_from_if<S: Source>(
self,
source: &mut S
) -> Result<Option<bool>, DecodeError<S::Error>>
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.
sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Returns the number of octets of the encoded form of the tag.