[−][src]Struct bsn1::Id
Id owns IdRef and represents Identifier.
Note that this struct may allocate heap memory if the number is very large, because ASN.1 does
not limit the length of identifier bytes, however, it uses only stack memory at least the
number equals to or is less than usize::MAX .
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]
impl Eq for Id[src]
impl Hash for Id[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl Ord for Id[src]
fn cmp(&self, other: &Id) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl PartialEq<Id> for Id[src]
impl PartialOrd<Id> for Id[src]
fn partial_cmp(&self, other: &Id) -> Option<Ordering>[src]
fn lt(&self, other: &Id) -> bool[src]
fn le(&self, other: &Id) -> bool[src]
fn gt(&self, other: &Id) -> bool[src]
fn ge(&self, other: &Id) -> bool[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 so far, but this
functions returns Ok .
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,