pub struct TagNumber(/* private fields */);
Available on crate feature pkcs8 only.
Expand description

ASN.1 tag numbers (i.e. lower 5 bits of a Tag).

From X.690 Section 8.1.2.2:

bits 5 to 1 shall encode the number of the tag as a binary integer with bit 5 as the most significant bit.

This library supports tag numbers ranging from zero to 30 (inclusive), which can be represented as a single identifier octet.

Section 8.1.2.4 describes how to support multi-byte tag numbers, which are encoded by using a leading tag number of 31 (0b11111). This library deliberately does not support this: tag numbers greater than 30 are disallowed.

Implementations§

§

impl TagNumber

pub const N0: TagNumber = _

Tag number 0

pub const N1: TagNumber = _

Tag number 1

pub const N2: TagNumber = _

Tag number 2

pub const N3: TagNumber = _

Tag number 3

pub const N4: TagNumber = _

Tag number 4

pub const N5: TagNumber = _

Tag number 5

pub const N6: TagNumber = _

Tag number 6

pub const N7: TagNumber = _

Tag number 7

pub const N8: TagNumber = _

Tag number 8

pub const N9: TagNumber = _

Tag number 9

pub const N10: TagNumber = _

Tag number 10

pub const N11: TagNumber = _

Tag number 11

pub const N12: TagNumber = _

Tag number 12

pub const N13: TagNumber = _

Tag number 13

pub const N14: TagNumber = _

Tag number 14

pub const N15: TagNumber = _

Tag number 15

pub const N16: TagNumber = _

Tag number 16

pub const N17: TagNumber = _

Tag number 17

pub const N18: TagNumber = _

Tag number 18

pub const N19: TagNumber = _

Tag number 19

pub const N20: TagNumber = _

Tag number 20

pub const N21: TagNumber = _

Tag number 21

pub const N22: TagNumber = _

Tag number 22

pub const N23: TagNumber = _

Tag number 23

pub const N24: TagNumber = _

Tag number 24

pub const N25: TagNumber = _

Tag number 25

pub const N26: TagNumber = _

Tag number 26

pub const N27: TagNumber = _

Tag number 27

pub const N28: TagNumber = _

Tag number 28

pub const N29: TagNumber = _

Tag number 29

pub const N30: TagNumber = _

Tag number 30

pub const fn new(byte: u8) -> TagNumber

Create a new tag number (const-friendly).

Panics if the tag number is greater than 30. For a fallible conversion, use TryFrom instead.

pub fn application(self, constructed: bool) -> Tag

Create an APPLICATION tag with this tag number.

pub fn context_specific(self, constructed: bool) -> Tag

Create a CONTEXT-SPECIFIC tag with this tag number.

pub fn private(self, constructed: bool) -> Tag

Create a PRIVATE tag with this tag number.

pub fn value(self) -> u8

Get the inner value.

Trait Implementations§

§

impl Clone for TagNumber

§

fn clone(&self) -> TagNumber

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
§

impl Debug for TagNumber

§

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

Formats the value using the given formatter. Read more
§

impl Display for TagNumber

§

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

Formats the value using the given formatter. Read more
§

impl Ord for TagNumber

§

fn cmp(&self, other: &TagNumber) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
§

impl PartialEq for TagNumber

§

fn eq(&self, other: &TagNumber) -> 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.
§

impl PartialOrd for TagNumber

§

fn partial_cmp(&self, other: &TagNumber) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl TryFrom<u8> for TagNumber

§

type Error = Error

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

fn try_from(byte: u8) -> Result<TagNumber, Error>

Performs the conversion.
§

impl Copy for TagNumber

§

impl Eq for TagNumber

§

impl StructuralPartialEq for TagNumber

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
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.