[−][src]Struct bsn1::Der
Der owns DerRef and represents DER.
Implementations
impl Der[src]
pub fn new(id: &IdRef, contents: &[u8]) -> Self[src]
Creates a new instance from id and contents .
Warnings
ASN.1 does not allow some universal identifier for DER, however, this function accepts
such an identifier.
For example, 'Octet String' must be primitive in DER, but this function will construct a
new instance even if id represenets constructed 'Octet String.'
Methods from Deref<Target = DerRef>
pub fn id(&self) -> &IdRef[src]
Returns a reference to IdRef of self .
Examples
use bsn1::{Der, IdRef}; let id = IdRef::octet_string(); let contents = &[1, 2, 3]; // 'DER' implements 'Deref<Target=DerRef>' let der = Der::new(id, contents); assert_eq!(id, der.id());
pub fn length(&self) -> Length[src]
Returns Length to represent the length of contents.
Note that DER does not allow indefinite Length.
The return value must be Length::Definite .
Warnings
Length stands for 'the length of the contents' in DER.
The length of the total bytes is greater than the value.
Examples
use bsn1::{Der, IdRef, Length}; let id = IdRef::octet_string(); let contents = &[1, 2, 3]; // 'DER' implements 'Deref<Target=DerRef>' let der = Der::new(id, contents); assert_eq!(Length::Definite(contents.len()), der.length());
pub fn contents(&self) -> &[u8][src]
Returns a reference to 'contents octets' of self .
Examples
use bsn1::{Der, IdRef}; let id = IdRef::octet_string(); let contents = &[1, 2, 3]; // 'DER' implements 'Deref<Target=DerRef>' let der = Der::new(id, contents); assert_eq!(contents, der.contents());
Trait Implementations
impl AsRef<[u8]> for Der[src]
impl AsRef<DerRef> for Der[src]
impl Borrow<[u8]> for Der[src]
impl Borrow<DerRef> for Der[src]
impl Clone for Der[src]
impl Debug for Der[src]
impl Deref for Der[src]
impl Eq for Der[src]
impl<'_> From<&'_ DerRef> for Der[src]
impl From<Der> for Ber[src]
impl PartialEq<Der> for Der[src]
impl StructuralEq for Der[src]
impl StructuralPartialEq for Der[src]
impl<'_> TryFrom<&'_ [u8]> for Der[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 starting with DER octets and builds a new instance.
This function ignores extra octet(s) at the end of bytes if any.
Warnings
ASN.1 does not allow some universal identifier for DER, however, this function accepts
such an identifier.
For example, 'Octet String' must be primitive in DER, but this function returns Ok for
constructed Octet String DER.
Auto Trait Implementations
impl RefUnwindSafe for Der
impl !Send for Der
impl !Sync for Der
impl Unpin for Der
impl UnwindSafe for Der
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>,