Struct bsn1::IdRef [−][src]
pub struct IdRef { /* fields omitted */ }Expand description
IdRef is a wrapper of [u8] represents Identifier.
This struct is Unsized , and user will usually use a reference to it.
Implementations
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);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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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());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
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
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 .