Struct der::Encoder [−][src]
pub struct Encoder<'a> { /* fields omitted */ }Expand description
DER encoder.
Implementations
impl<'a> Encoder<'a>[src]
impl<'a> Encoder<'a>[src]pub fn new(bytes: &'a mut [u8]) -> Self[src]
pub fn new(bytes: &'a mut [u8]) -> Self[src]Create a new encoder with the given byte slice as a backing buffer.
pub fn encode<T: Encodable>(&mut self, encodable: &T) -> Result<()>[src]
pub fn encode<T: Encodable>(&mut self, encodable: &T) -> Result<()>[src]Encode a value which impls the Encodable trait.
pub fn error<T>(&mut self, kind: ErrorKind) -> Result<T>[src]
pub fn error<T>(&mut self, kind: ErrorKind) -> Result<T>[src]Return an error with the given ErrorKind, annotating it with
context about where the error occurred.
pub fn finish(self) -> Result<&'a [u8]>[src]
pub fn finish(self) -> Result<&'a [u8]>[src]Finish encoding to the buffer, returning a slice containing the data written to the buffer.
pub fn bit_string(&mut self, value: impl TryInto<BitString<'a>>) -> Result<()>[src]
pub fn bit_string(&mut self, value: impl TryInto<BitString<'a>>) -> Result<()>[src]Encode the provided value as an ASN.1 BIT STRING
pub fn generalized_time(
&mut self,
value: impl TryInto<GeneralizedTime>
) -> Result<()>[src]
pub fn generalized_time(
&mut self,
value: impl TryInto<GeneralizedTime>
) -> Result<()>[src]Encode the provided value as an ASN.1 GeneralizedTime
pub fn ia5_string(&mut self, value: impl TryInto<Ia5String<'a>>) -> Result<()>[src]
pub fn ia5_string(&mut self, value: impl TryInto<Ia5String<'a>>) -> Result<()>[src]Encode the provided value as an ASN.1 IA5String
pub fn message(&mut self, fields: &[&dyn Encodable]) -> Result<()>[src]
pub fn message(&mut self, fields: &[&dyn Encodable]) -> Result<()>[src]Encode a message with the provided Encodable fields as an
ASN.1 SEQUENCE.
pub fn octet_string(
&mut self,
value: impl TryInto<OctetString<'a>>
) -> Result<()>[src]
pub fn octet_string(
&mut self,
value: impl TryInto<OctetString<'a>>
) -> Result<()>[src]Encode the provided value as an ASN.1 OCTET STRING
pub fn oid(&mut self, value: impl TryInto<ObjectIdentifier>) -> Result<()>[src]
This is supported on crate feature oid only.
pub fn oid(&mut self, value: impl TryInto<ObjectIdentifier>) -> Result<()>[src]oid only.Encode an ASN.1 ObjectIdentifier
pub fn printable_string(
&mut self,
value: impl TryInto<PrintableString<'a>>
) -> Result<()>[src]
pub fn printable_string(
&mut self,
value: impl TryInto<PrintableString<'a>>
) -> Result<()>[src]Encode the provided value as an ASN.1 PrintableString
pub fn sequence<F>(&mut self, length: Length, f: F) -> Result<()> where
F: FnOnce(&mut Encoder<'_>) -> Result<()>, [src]
pub fn sequence<F>(&mut self, length: Length, f: F) -> Result<()> where
F: FnOnce(&mut Encoder<'_>) -> Result<()>, [src]Encode an ASN.1 SEQUENCE of the given length.
Spawns a nested Encoder which is expected to be exactly the
specified length upon completion.
pub fn utc_time(&mut self, value: impl TryInto<UtcTime>) -> Result<()>[src]
pub fn utc_time(&mut self, value: impl TryInto<UtcTime>) -> Result<()>[src]Encode the provided value as an ASN.1 UTCTime
pub fn utf8_string(&mut self, value: impl TryInto<Utf8String<'a>>) -> Result<()>[src]
pub fn utf8_string(&mut self, value: impl TryInto<Utf8String<'a>>) -> Result<()>[src]Encode the provided value as an ASN.1 Utf8String