Struct der_parser::DerObject

source ·
pub struct DerObject<'a> {
    pub class: u8,
    pub structured: u8,
    pub tag: u8,
    pub content: DerObjectContent<'a>,
}
Expand description

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

Fields

class: u8structured: u8tag: u8content: DerObjectContent<'a>

Implementations

Build a DerObject 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.

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

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

Build a DER sequence object from a vector of DER objects

Build a DER set object from a vector of DER objects

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  = DerObject::from_obj(DerObjectContent::Integer(b"\x01\x00\x01"));
assert_eq!(
    der_int.as_u64(),
    Ok(0x10001)
);

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  = DerObject::from_obj(DerObjectContent::Integer(b"\x01\x00\x01"));
assert_eq!(
    der_int.as_u32(),
    Ok(0x10001)
);

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

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

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

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

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.

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

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

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

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

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.

Test if object class is Universal

Test if object class is Application

Test if object class is Context-specific

Test if object class is Private

Test if object is primitive

Test if object is constructed

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Build a DER object from a DerObjectContent.

Converts to this type from the input type.

Build a DER object from an OID.

Converts to this type from the input type.
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.