Struct bsn1::Id[][src]

pub struct Id { /* fields omitted */ }
Expand description

Id owns IdRef and represents Identifier.

Implementations

impl Id[src]

pub fn new(class: ClassTag, pc: PCTag, number: u128) -> Self[src]

Creates a new instance from class , pc , and number .

Warnings

ASN.1 reserves some universal identifier numbers and they should not be used, however, this function ignores that. For example, number 15 (0x0f) is reserved so far, but this function accepts such a number.

Examples

use bsn1::{ClassTag, Id, PCTag};

// Creates 'Universal Integer'
let _id = Id::new(ClassTag::Universal, PCTag::Primitive, 2);

Methods from Deref<Target = IdRef>

pub fn class(&self) -> ClassTag[src]

Returns ClassTag of self .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Universal, PCTag::Primitive, 0);
assert_eq!(ClassTag::Universal, id.class());

let id = Id::new(ClassTag::Application, PCTag::Constructed, 1);
assert_eq!(ClassTag::Application, id.class());

let id = Id::new(ClassTag::ContextSpecific, PCTag::Primitive, 2);
assert_eq!(ClassTag::ContextSpecific, id.class());

let id = Id::new(ClassTag::Private, PCTag::Constructed, 3);
assert_eq!(ClassTag::Private, id.class());

pub fn is_universal(&self) -> bool[src]

Returns true if self is ‘Universal’ class, or false .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Universal, PCTag::Primitive, 0);
assert_eq!(true, id.is_universal());

pub fn is_application(&self) -> bool[src]

Returns true if self is ‘Application’ class, or false .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Application, PCTag::Primitive, 0);
assert_eq!(true, id.is_application());

pub fn is_context_specific(&self) -> bool[src]

Returns true if self is ‘Context Specific’ class, or false .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::ContextSpecific, PCTag::Primitive, 0);
assert_eq!(true, id.is_context_specific());

pub fn is_private(&self) -> bool[src]

Returns true if self is ‘Private’ class, or false .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Private, PCTag::Primitive, 0);
assert_eq!(true, id.is_private());

pub fn pc(&self) -> PCTag[src]

Returns the Primitive/Constructed flag of self .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Universal, PCTag::Primitive, 0);
assert_eq!(PCTag::Primitive, id.pc());

let id = Id::new(ClassTag::Application, PCTag::Constructed, 1);
assert_eq!(PCTag::Constructed, id.pc());

pub fn is_primitive(&self) -> bool[src]

Returns true if self is flagged as ‘Primitive’, or false .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Universal, PCTag::Primitive, 0);
assert_eq!(true, id.is_primitive());

pub fn is_constructed(&self) -> bool[src]

Returns true if self is flagged as ‘Constructed’, or false .

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Universal, PCTag::Constructed, 0);
assert_eq!(true, id.is_constructed());

pub fn number(&self) -> Result<u128, Error>[src]

Returns the number of self unless overflow.

Examples

use bsn1::{ClassTag, Id, PCTag};

// 'Id' implements 'Deref<Target = IdRef>'.
let id = Id::new(ClassTag::Application, PCTag::Primitive, 49);
assert_eq!(49, id.number().unwrap());

Trait Implementations

impl AsRef<[u8]> for Id[src]

fn as_ref(&self) -> &[u8][src]

Performs the conversion.

impl AsRef<IdRef> for Id[src]

fn as_ref(&self) -> &IdRef[src]

Performs the conversion.

impl Borrow<[u8]> for Id[src]

fn borrow(&self) -> &[u8][src]

Immutably borrows from an owned value. Read more

impl Borrow<IdRef> for Id[src]

fn borrow(&self) -> &IdRef[src]

Immutably borrows from an owned value. Read more

impl Clone for Id[src]

fn clone(&self) -> Id[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Id[src]

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

Formats the value using the given formatter. Read more

impl Deref for Id[src]

type Target = IdRef

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl Hash for Id[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for Id[src]

fn cmp(&self, other: &Id) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Id> for Id[src]

fn eq(&self, other: &Id) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Id) -> bool[src]

This method tests for !=.

impl PartialOrd<Id> for Id[src]

fn partial_cmp(&self, other: &Id) -> Option<Ordering>[src]

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

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

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

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

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

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

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

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

impl TryFrom<&'_ [u8]> for Id[src]

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>[src]

Parses bytes starts with identifier octets and tries to build a new instance.

This function ignores the extra octet(s) at the end if any.

Warnings

Warnings

ASN.1 reserves some universal identifier numbers and they should not be used, however, this function ignores that. For example, number 15 (0x0f) is reserved for now, but this functions returns Ok .

type Error = Error

The type returned in the event of a conversion error.

impl Eq for Id[src]

impl StructuralEq for Id[src]

impl StructuralPartialEq for Id[src]

Auto Trait Implementations

impl RefUnwindSafe for Id

impl Send for Id

impl Sync for Id

impl Unpin for Id

impl UnwindSafe for Id

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.