Struct bsn1::IdRef [−][src]
IdRef is a wrapper of [u8] represents Identifier.
This struct is Unsized , and user will usually use a reference to it.
Implementations
impl IdRef[src]
pub unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self[src]
Provides a reference from bytes without any sanitize.
bytes must not include any extra octets.
If it is not sure whether bytes is valid octets as an identifer or not, use TryFrom
implementation instead.
Safety
The behavior is undefined if the format of bytes is not right.
Examples
use bsn1::{ClassTag, Id, IdRef, PCTag}; let id = Id::new(ClassTag::Universal, PCTag::Primitive, 0); let idref = unsafe { IdRef::from_bytes_unchecked(id.as_ref() as &[u8]) }; assert_eq!(id.as_ref() as &IdRef, idref);
pub fn eoc() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal EOC.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::eoc(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x00, id.number().unwrap());
pub fn boolean() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Boolean.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::boolean(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x01, id.number().unwrap());
pub fn integer() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Integer.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::integer(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x02, id.number().unwrap());
pub fn bit_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Bit String’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::bit_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x03, id.number().unwrap());
pub fn bit_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Bit String’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::bit_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x03, id.number().unwrap());
pub fn octet_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Octet String’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::octet_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x04, id.number().unwrap());
pub fn octet_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Octet String’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::octet_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x04, id.number().unwrap());
pub fn null() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Null.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::null(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x05, id.number().unwrap());
pub fn object_identifier() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Object Identifier.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::object_identifier(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x06, id.number().unwrap());
pub fn object_descriptor() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Object Descriptor’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::object_descriptor(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x07, id.number().unwrap());
pub fn external() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal External.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::external(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x08, id.number().unwrap());
pub fn real() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Real.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::real(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x09, id.number().unwrap());
pub fn enumerated() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Enumerated.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::enumerated(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x0a, id.number().unwrap());
pub fn embedded_pdv() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Embedded PDV.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::embedded_pdv(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x0b, id.number().unwrap());
pub fn utf8_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal UTF8 String’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::utf8_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x0c, id.number().unwrap());
pub fn utf8_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal UTF8 String’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::utf8_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x0c, id.number().unwrap());
pub fn relative_oid() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal UTF8 OID.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::relative_oid(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x0d, id.number().unwrap());
pub fn sequence() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Sequence’ or ‘Universal Sequence
of.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::sequence(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x10, id.number().unwrap());
pub fn set() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Set’ or ‘Universal Set of.’
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::set(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x11, id.number().unwrap());
pub fn numeric_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Numeric String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::numeric_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x12, id.number().unwrap());
pub fn numeric_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Numeric String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::numeric_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x12, id.number().unwrap());
pub fn printable_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Printable String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::printable_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x13, id.number().unwrap());
pub fn printable_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Printable String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::printable_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x13, id.number().unwrap());
pub fn t61_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal T61 String’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::t61_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x14, id.number().unwrap());
pub fn t61_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal T61 String’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::t61_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x14, id.number().unwrap());
pub fn videotex_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Videotex String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::videotex_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x15, id.number().unwrap());
pub fn videotex_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Videotex String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::videotex_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x15, id.number().unwrap());
pub fn ia5_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal IA5 String’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::ia5_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x16, id.number().unwrap());
pub fn ia5_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal IA5 String’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::ia5_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x16, id.number().unwrap());
pub fn utc_time() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal UTC Time’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::utc_time(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x17, id.number().unwrap());
pub fn utc_time_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal UTC Time’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::utc_time_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x17, id.number().unwrap());
pub fn generalized_time() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Generalized Time’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::generalized_time(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x18, id.number().unwrap());
pub fn generalized_time_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Generalized Time’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::generalized_time_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x18, id.number().unwrap());
pub fn graphic_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Graphic String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::graphic_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x19, id.number().unwrap());
pub fn graphic_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Graphic String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::graphic_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x19, id.number().unwrap());
pub fn visible_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Visible String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::visible_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x1a, id.number().unwrap());
pub fn visible_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Visible String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::visible_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x1a, id.number().unwrap());
pub fn general_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal General String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::general_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x1b, id.number().unwrap());
pub fn general_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal General String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::general_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x1b, id.number().unwrap());
pub fn universal_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Universal String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::universal_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x1c, id.number().unwrap());
pub fn universal_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Universal String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::universal_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x1c, id.number().unwrap());
pub fn character_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Character String’ with primitive
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::character_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x1d, id.number().unwrap());
pub fn character_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal Character String’ with constructed
flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::character_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x1d, id.number().unwrap());
pub fn bmp_string() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal BMP String’ with primitive flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::bmp_string(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Primitive, id.pc()); assert_eq!(0x1e, id.number().unwrap());
pub fn bmp_string_constructed() -> &'static Self[src]
Provides a reference to IdRef representing ‘Universal BMP String’ with constructed flag.
Examples
use bsn1::{ClassTag, IdRef, PCTag}; let id = IdRef::bmp_string_constructed(); assert_eq!(ClassTag::Universal, id.class()); assert_eq!(PCTag::Constructed, id.pc()); assert_eq!(0x1e, id.number().unwrap());
impl IdRef[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]
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 IdRef[src]
impl AsRef<IdRef> for Id[src]
impl Borrow<[u8]> for IdRef[src]
impl Borrow<IdRef> for Id[src]
impl Debug for IdRef[src]
impl Eq for IdRef[src]
impl Hash for IdRef[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl Ord for IdRef[src]
fn cmp(&self, other: &IdRef) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self1.50.0[src]
impl PartialEq<IdRef> for IdRef[src]
impl PartialOrd<IdRef> for IdRef[src]
fn partial_cmp(&self, other: &IdRef) -> Option<Ordering>[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl StructuralEq for IdRef[src]
impl StructuralPartialEq for IdRef[src]
impl ToOwned for IdRef[src]
type Owned = Id
The resulting type after obtaining ownership.
fn to_owned(&self) -> Self::Owned[src]
pub fn clone_into(&self, target: &mut Self::Owned)[src]
impl<'a> TryFrom<&'a [u8]> for &'a IdRef[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error>[src]
Parses bytes starts with identifier and tries to build a new instance.
This function ignores the extra octet(s) at the end if any.
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 .