[][src]Struct der_parser::ber::BerObject

pub struct BerObject<'a> {
    pub class: BerClass,
    pub structured: u8,
    pub tag: BerTag,
    pub content: BerObjectContent<'a>,
    pub raw_tag: Option<&'a [u8]>,
}

Representation of a DER-encoded (X.690) object

Fields

class: BerClassstructured: u8tag: BerTagcontent: BerObjectContent<'a>raw_tag: Option<&'a [u8]>

Methods

impl<'a> BerObject<'a>[src]

pub fn as_bigint(&self) -> Option<BigInt>[src]

pub fn as_biguint(&self) -> Option<BigUint>[src]

impl<'a> BerObject<'a>[src]

pub fn from_header_and_content<'hdr>(
    hdr: BerObjectHeader<'hdr>,
    c: BerObjectContent<'hdr>
) -> BerObject<'hdr>
[src]

Build a BerObject from a header and content. Note: values are not checked, so the tag can be different from the real content, or flags can be invalid.

pub fn from_obj(c: BerObjectContent) -> BerObject[src]

Build a BerObject from its content, using default flags (no class, correct tag, and structured flag set only for Set and Sequence)

pub fn from_int_slice(i: &'a [u8]) -> BerObject<'a>[src]

Build a DER integer object from a slice containing an encoded integer

pub fn set_raw_tag(self, raw_tag: Option<&'a [u8]>) -> BerObject[src]

Set a tag for the BER object

pub fn from_seq(l: Vec<BerObject>) -> BerObject[src]

Build a DER sequence object from a vector of DER objects

pub fn from_set(l: Vec<BerObject>) -> BerObject[src]

Build a DER set object from a vector of DER objects

pub fn to_header(&self) -> BerObjectHeader[src]

Build a BER header from this object (len is set to 0)

pub fn as_u64(&self) -> Result<u64, BerError>[src]

Attempt to read integer value from DER object. This can fail if the object is not an integer, or if it is too large.

let der_int  = BerObject::from_int_slice(b"\x01\x00\x01");
assert_eq!(
    der_int.as_u64(),
    Ok(0x10001)
);

pub fn as_u32(&self) -> Result<u32, BerError>[src]

Attempt to read integer value from DER object. This can fail if the object is not an integer, or if it is too large.

let der_int  = BerObject::from_obj(BerObjectContent::Integer(b"\x01\x00\x01"));
assert_eq!(
    der_int.as_u32(),
    Ok(0x10001)
);

pub fn as_bool(&self) -> Result<bool, BerError>[src]

Attempt to read integer value from DER object. This can fail if the object is not a boolean.

pub fn as_oid(&self) -> Result<&Oid<'a>, BerError>[src]

Attempt to read an OID value from DER object. This can fail if the object is not an OID.

pub fn as_oid_val(&self) -> Result<Oid<'a>, BerError>[src]

Attempt to read an OID value from DER object. This can fail if the object is not an OID.

pub fn as_context_specific(
    &self
) -> Result<(BerTag, Option<Box<BerObject<'a>>>), BerError>
[src]

Attempt to read the content from a context-specific DER object. This can fail if the object is not context-specific.

Note: the object is cloned.

pub fn as_bitstring_ref(&self) -> Result<&BitStringObject, BerError>[src]

Attempt to read a reference to a BitString value from DER object. This can fail if the object is not an BitString.

Note that this function returns a reference to the BitString. To get an owned value, use as_bitstring

pub fn as_bitstring(&'a self) -> Result<BitStringObject<'a>, BerError>[src]

Attempt to read a BitString value from DER object. This can fail if the object is not an BitString.

pub fn as_sequence(&self) -> Result<&Vec<BerObject<'a>>, BerError>[src]

Attempt to extract the list of objects from a DER sequence. This can fail if the object is not a sequence.

pub fn as_set(&self) -> Result<&Vec<BerObject<'a>>, BerError>[src]

Attempt to extract the list of objects from a DER set. This can fail if the object is not a set.

pub fn as_slice(&self) -> Result<&'a [u8], BerError>[src]

Attempt to get the content from a DER object, as a slice. This can fail if the object does not contain a type directly equivalent to a slice (e.g a sequence). This function mostly concerns string types, integers, or unknown DER objects.

pub fn as_str(&self) -> Result<&'a str, BerError>[src]

Attempt to get the content from a DER object, as a str. This can fail if the object does not contain a string type.

Only NumericString, PrintableString, UTF8String and IA5String are considered here. Other string types can be read using as_slice.

pub fn is_universal(&self) -> bool[src]

Test if object class is Universal

pub fn is_application(&self) -> bool[src]

Test if object class is Application

pub fn is_contextspecific(&self) -> bool[src]

Test if object class is Context-specific

pub fn is_private(&self) -> bool[src]

Test if object class is Private

pub fn is_primitive(&self) -> bool[src]

Test if object is primitive

pub fn is_constructed(&self) -> bool[src]

Test if object is constructed

impl<'a> BerObject<'a>[src]

pub fn ref_iter(&'a self) -> BerObjectRefIterator<'a>[src]

impl<'a> BerObject<'a>[src]

pub fn as_pretty(&'a self, indent: usize, increment: usize) -> PrettyBer<'a>[src]

impl<'a> BerObject<'a>[src]

pub fn to_vec(&self) -> Result<Vec<u8>, GenError>[src]

Attempt to encode object as BER

Note that the encoding will not check that the values of the BerObject fields are correct. The length is automatically calculated, and the field is ignored.

ContextSpecific objects will be encoded as EXPLICIT.

This function is only available if the serialize feature is enabled.

Trait Implementations

impl<'a> Clone for BerObject<'a>[src]

impl<'a> Debug for BerObject<'a>[src]

impl<'a> From<BerObjectContent<'a>> for BerObject<'a>[src]

Build a DER object from a BerObjectContent.

impl<'a> From<Oid<'a>> for BerObject<'a>[src]

Build a DER object from an OID.

impl<'a> Index<usize> for BerObject<'a>[src]

type Output = BerObject<'a>

The returned type after indexing.

impl<'a> IntoIterator for BerObject<'a>[src]

type Item = BerObject<'a>

The type of the elements being iterated over.

type IntoIter = BerObjectIntoIterator<'a>

Which kind of iterator are we turning this into?

impl<'a> PartialEq<BerObject<'a>> for BerObject<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for BerObject<'a>

impl<'a> Send for BerObject<'a>

impl<'a> Sync for BerObject<'a>

impl<'a> Unpin for BerObject<'a>

impl<'a> UnwindSafe for BerObject<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.