TagNumber

Struct TagNumber 

Source
pub struct TagNumber(/* private fields */);
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§

Source§

impl TagNumber

Source

pub const N0: Self

Tag number 0

Source

pub const N1: Self

Tag number 1

Source

pub const N2: Self

Tag number 2

Source

pub const N3: Self

Tag number 3

Source

pub const N4: Self

Tag number 4

Source

pub const N5: Self

Tag number 5

Source

pub const N6: Self

Tag number 6

Source

pub const N7: Self

Tag number 7

Source

pub const N8: Self

Tag number 8

Source

pub const N9: Self

Tag number 9

Source

pub const N10: Self

Tag number 10

Source

pub const N11: Self

Tag number 11

Source

pub const N12: Self

Tag number 12

Source

pub const N13: Self

Tag number 13

Source

pub const N14: Self

Tag number 14

Source

pub const N15: Self

Tag number 15

Source

pub const N16: Self

Tag number 16

Source

pub const N17: Self

Tag number 17

Source

pub const N18: Self

Tag number 18

Source

pub const N19: Self

Tag number 19

Source

pub const N20: Self

Tag number 20

Source

pub const N21: Self

Tag number 21

Source

pub const N22: Self

Tag number 22

Source

pub const N23: Self

Tag number 23

Source

pub const N24: Self

Tag number 24

Source

pub const N25: Self

Tag number 25

Source

pub const N26: Self

Tag number 26

Source

pub const N27: Self

Tag number 27

Source

pub const N28: Self

Tag number 28

Source

pub const N29: Self

Tag number 29

Source

pub const N30: Self

Tag number 30

Source

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

Create a new tag number (const-friendly).

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

Source

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

Create an APPLICATION tag with this tag number.

Source

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

Create a CONTEXT-SPECIFIC tag with this tag number.

Source

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

Create a PRIVATE tag with this tag number.

Source

pub fn value(self) -> u8

Get the inner value.

Trait Implementations§

Source§

impl Clone for TagNumber

Source§

fn clone(&self) -> TagNumber

Returns a duplicate 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 TagNumber

Source§

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

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

impl Display for TagNumber

Source§

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

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

impl From<TagNumber> for u8

Source§

fn from(tag_number: TagNumber) -> u8

Converts to this type from the input type.
Source§

impl Ord for TagNumber

Source§

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,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for TagNumber

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for TagNumber

Source§

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

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

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

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

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

impl TryFrom<u8> for TagNumber

Source§

type Error = Error

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

fn try_from(byte: u8) -> Result<Self>

Performs the conversion.
Source§

impl Copy for TagNumber

Source§

impl Eq for TagNumber

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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§

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

Source§

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

Source§

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 1 byte