Enum der::Tag

source ·
#[non_exhaustive]
pub enum Tag {
Show 20 variants Boolean, Integer, BitString, OctetString, Null, ObjectIdentifier, Enumerated, Utf8String, Sequence, Set, NumericString, PrintableString, Ia5String, UtcTime, GeneralizedTime, VisibleString, BmpString, Application { constructed: bool, number: TagNumber, }, ContextSpecific { constructed: bool, number: TagNumber, }, Private { constructed: bool, number: TagNumber, },
}
Expand description

ASN.1 tags.

Tags are the leading identifier octet of the Tag-Length-Value encoding used by ASN.1 DER and identify the type of the subsequent value.

They are described in X.690 Section 8.1.2: Identifier octets, and structured as follows:

| Class | P/C | Tag Number |
  • Bits 8/7: Class
  • Bit 6: primitive (0) or constructed (1)
  • Bits 5-1: tag number

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Boolean

BOOLEAN tag: 1.

§

Integer

INTEGER tag: 2.

§

BitString

BIT STRING tag: 3.

§

OctetString

OCTET STRING tag: 4.

§

Null

NULL tag: 5.

§

ObjectIdentifier

OBJECT IDENTIFIER tag: 6.

§

Enumerated

ENUMERATED tag: 10.

§

Utf8String

UTF8String tag: 12.

§

Sequence

SEQUENCE tag: 16.

§

Set

SET and SET OF tag: 17.

§

NumericString

NumericString tag: 18.

§

PrintableString

PrintableString tag: 19.

§

Ia5String

IA5String tag: 22.

§

UtcTime

UTCTime tag: 23.

§

GeneralizedTime

GeneralizedTime tag: 24.

§

VisibleString

VisibleString tag: 26.

§

BmpString

BMPString tag: 30.

§

Application

Fields

§constructed: bool

Is this tag constructed? (vs primitive).

§number: TagNumber

Tag number.

Application tag.

§

ContextSpecific

Fields

§constructed: bool

Is this tag constructed? (vs primitive).

§number: TagNumber

Tag number.

Context-specific tag.

§

Private

Fields

§constructed: bool

Is this tag constructed? (vs primitive).

§number: TagNumber

Tag number.

Private tag number.

Implementations§

Assert that this Tag matches the provided expected tag.

On mismatch, returns an Error with ErrorKind::TagUnexpected.

Get the Class that corresponds to this Tag.

Get the TagNumber (lower 6-bits) for this tag.

Does this tag represent a constructed (as opposed to primitive) field?

Is this an application tag?

Is this a context-specific tag?

Is this a private tag?

Is this a universal tag?

Get the octet encoding for this Tag.

Create an Error for an invalid Length.

Create an Error for an non-canonical value with the ASN.1 type identified by this tag.

Create an Error because the current tag was unexpected, with an optional expected tag.

Create an Error for an invalid value with the ASN.1 type identified by this tag.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Attempt to decode this message using the provided decoder.
Parse Self from the provided DER-encoded byte slice.
Return an Ordering between self and other when serialized as ASN.1 DER. Read more
Formats the value using the given formatter. Read more
Compute the length of this value in bytes when encoded as ASN.1 DER.
Encode this value as ASN.1 DER using the provided Encoder.
Encode this value to the provided byte slice, returning a sub-slice containing the encoded message. Read more
Converts to this type from the input type.
Converts to this type from the input type.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.