Struct bsn1::Id[][src]

pub struct Id { /* fields omitted */ }

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]

impl AsRef<IdRef> for Id[src]

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

impl Borrow<IdRef> for Id[src]

impl Clone for Id[src]

impl Debug for Id[src]

impl Deref for Id[src]

type Target = IdRef

The resulting type after dereferencing.

impl Eq for Id[src]

impl Hash for Id[src]

impl Ord for Id[src]

impl PartialEq<Id> for Id[src]

impl PartialOrd<Id> for Id[src]

impl StructuralEq for Id[src]

impl StructuralPartialEq for Id[src]

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

type Error = Error

The type returned in the event of a conversion error.

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 .

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]

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.