Struct bsn1::Id [−][src]
pub struct Id { /* fields omitted */ }
Expand description
Id
owns IdRef
and represents Identifier.
Implementations
impl Id
[src]
impl Id
[src]pub fn new(class: ClassTag, pc: PCTag, number: u128) -> Self
[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]
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]
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]
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]
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]
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]
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]
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]
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());
Trait Implementations
impl Ord for Id
[src]
impl Ord for Id
[src]impl PartialOrd<Id> for Id
[src]
impl PartialOrd<Id> for Id
[src]fn partial_cmp(&self, other: &Id) -> Option<Ordering>
[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]
#[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]
#[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
impl TryFrom<&'_ [u8]> for Id
[src]
impl TryFrom<&'_ [u8]> for Id
[src]fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>
[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
.
impl Eq for Id
[src]
impl StructuralEq for Id
[src]
impl StructuralPartialEq for Id
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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