pub struct Tag(_);
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.
At the moment, you can only compare two tags. All necessary values are defined as associated constants; there is no other way to create new tag values.
Limitations
At this time, we can only decode single-octet identifier octets. That is, we only support tag numbers between 0 and 30.
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, UNIVERAL 10.
sourcepub const EMBEDDED_PDV: Self = _
pub const EMBEDDED_PDV: Self = _
The tag for the EMBEDDED PDV type, UNIVERAL 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, UNIVERAL 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, UNIVERAL 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 BMP_STRING: Self = _
pub const BMP_STRING: Self = _
The tag for the BMPString type, UNIVERSAL 29.
source§impl Tag
impl Tag
sourcepub fn universal(number: u8) -> Self
pub fn universal(number: u8) -> 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 30.
sourcepub fn application(number: u8) -> Self
pub fn application(number: u8) -> 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 30.
sourcepub fn context_specific(number: u8) -> Self
pub fn context_specific(number: u8) -> Self
Creates a new tag in the context specific class.
Panics
Currently, this function panics if the provided tag number is greater than 30.
sourcepub fn private(number: u8) -> Self
pub fn private(number: u8) -> 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 30.
sourcepub fn take_from<S: Source>(source: &mut S) -> Result<(Self, bool), S::Err>
pub fn take_from<S: Source>(source: &mut S) -> Result<(Self, bool), S::Err>
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>, S::Err>
pub fn take_from_if<S: Source>(
self,
source: &mut S
) -> Result<Option<bool>, S::Err>
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.