pub struct Sequence<'a> { /* private fields */ }
Expand description
An ASN.1-DER sequence view
Implementations§
source§impl<'a> Sequence<'a>
impl<'a> Sequence<'a>
sourcepub fn new<S: Sink + Into<&'a [u8]>, T: DerEncodable>(
objs: &[T],
sink: S
) -> Result<Self, Asn1DerError>
pub fn new<S: Sink + Into<&'a [u8]>, T: DerEncodable>( objs: &[T], sink: S ) -> Result<Self, Asn1DerError>
Writes a new sequence object with objs
as subobjects into sink
and returns a type view
over it
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The amount of subelements in the sequence
Note: since there is no underlying index, the amount of subelements has to be recomputed every time. If you need the length more than once, consider caching it.
sourcepub fn get(&self, n: usize) -> Result<DerObject<'a>, Asn1DerError>
pub fn get(&self, n: usize) -> Result<DerObject<'a>, Asn1DerError>
Gets the n
th subobject
Note: since there is no underlying index, the position of each subelement has to be recomputed every time. If you need the subobjects more than once, consider caching them.
sourcepub fn get_as<T: DerDecodable<'a>>(&self, n: usize) -> Result<T, Asn1DerError>
pub fn get_as<T: DerDecodable<'a>>(&self, n: usize) -> Result<T, Asn1DerError>
Gets the n
th subobject as T
Note: since there is no underlying index, the position of each subelement has to be recomputed every time. If you need the subobjects more than once, consider caching them.
sourcepub fn write<S: Sink, T: DerEncodable>(
objs: &[T],
sink: &mut S
) -> Result<(), Asn1DerError>
pub fn write<S: Sink, T: DerEncodable>( objs: &[T], sink: &mut S ) -> Result<(), Asn1DerError>
Writes a sequence consisting of objs
as DER-object to sink
Trait Implementations§
source§impl<'a> DerDecodable<'a> for Sequence<'a>
impl<'a> DerDecodable<'a> for Sequence<'a>
source§fn load(object: DerObject<'a>) -> Result<Self, Asn1DerError>
fn load(object: DerObject<'a>) -> Result<Self, Asn1DerError>
Loads the Sequence
and performs a shallow validation that each underlying object is a
valid DER object
Note: This function does not look “into” the underlying elements nor does it perform any type-specific validation – only the tag-length constructions are validated.
source§fn decode_at(raw: &'a [u8], header_start: usize) -> Result<Self, Asn1DerError>
fn decode_at(raw: &'a [u8], header_start: usize) -> Result<Self, Asn1DerError>
Self
source§fn decode_from_source<A: Source, B: Sink + Into<&'a [u8]>>(
source: &mut A,
sink: B
) -> Result<Self, Asn1DerError>
fn decode_from_source<A: Source, B: Sink + Into<&'a [u8]>>( source: &mut A, sink: B ) -> Result<Self, Asn1DerError>
source
by parsing the length field and copying the necessary bytes
into sink
and decoding it from sink