pub struct Decoder<'a> { /* private fields */ }
Expand description
DER decoder.
Implementations
sourceimpl<'a> Decoder<'a>
impl<'a> Decoder<'a>
sourcepub fn decode<T: Decodable<'a>>(&mut self) -> Result<T>
pub fn decode<T: Decodable<'a>>(&mut self) -> Result<T>
Decode a value which impls the Decodable
trait.
sourcepub fn error(&mut self, kind: ErrorKind) -> Error
pub fn error(&mut self, kind: ErrorKind) -> Error
Return an error with the given ErrorKind
, annotating it with
context about where the error occurred.
sourcepub fn value_error(&mut self, tag: Tag) -> Error
pub fn value_error(&mut self, tag: Tag) -> Error
Return an error for an invalid value with the given tag.
sourcepub fn finish<T>(self, value: T) -> Result<T>
pub fn finish<T>(self, value: T) -> Result<T>
Finish decoding, returning the given value if there is no remaining data, or an error otherwise
sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Have we decoded all of the bytes in this Decoder
?
Returns false
if we’re not finished decoding or if a fatal error
has occurred.
sourcepub fn any_optional(&mut self) -> Result<Option<Any<'a>>>
pub fn any_optional(&mut self) -> Result<Option<Any<'a>>>
Attempt to decode an OPTIONAL
ASN.1 ANY
value.
sourcepub fn uint_bytes(&mut self) -> Result<UIntBytes<'a>>
pub fn uint_bytes(&mut self) -> Result<UIntBytes<'a>>
Attempt to decode an ASN.1 INTEGER
as a UIntBytes
.
sourcepub fn bit_string(&mut self) -> Result<BitString<'a>>
pub fn bit_string(&mut self) -> Result<BitString<'a>>
Attempt to decode an ASN.1 BIT STRING
.
sourcepub fn context_specific(&mut self, tag: TagNumber) -> Result<Option<Any<'a>>>
pub fn context_specific(&mut self, tag: TagNumber) -> Result<Option<Any<'a>>>
Attempt to decode an ASN.1 CONTEXT-SPECIFIC
field with the
provided TagNumber
.
This method has the following behavior which is designed to simplify
handling of extension fields, which are denoted in an ASN.1 schema
using the ...
ellipsis extension marker:
- Skips over
ContextSpecific
fields with a tag number lower than the current one, consuming and ignoring them. - Returns
Ok(None)
if aContextSpecific
field with a higher tag number is encountered. These fields are not consumed in this case, allowing a field with a lower tag number to be omitted, then the higher numbered field consumed as a follow-up. - Returns
Ok(None)
if anything other than aContextSpecific
field is encountered.
sourcepub fn generalized_time(&mut self) -> Result<GeneralizedTime>
pub fn generalized_time(&mut self) -> Result<GeneralizedTime>
Attempt to decode an ASN.1 GeneralizedTime
.
sourcepub fn ia5_string(&mut self) -> Result<Ia5String<'a>>
pub fn ia5_string(&mut self) -> Result<Ia5String<'a>>
Attempt to decode an ASN.1 IA5String
.
sourcepub fn octet_string(&mut self) -> Result<OctetString<'a>>
pub fn octet_string(&mut self) -> Result<OctetString<'a>>
Attempt to decode an ASN.1 OCTET STRING
.
sourcepub fn oid(&mut self) -> Result<ObjectIdentifier>
pub fn oid(&mut self) -> Result<ObjectIdentifier>
Attempt to decode an ASN.1 OBJECT IDENTIFIER
.
sourcepub fn optional<T: Choice<'a>>(&mut self) -> Result<Option<T>>
pub fn optional<T: Choice<'a>>(&mut self) -> Result<Option<T>>
Attempt to decode an ASN.1 OPTIONAL
value.
sourcepub fn printable_string(&mut self) -> Result<PrintableString<'a>>
pub fn printable_string(&mut self) -> Result<PrintableString<'a>>
Attempt to decode an ASN.1 PrintableString
.
sourcepub fn utf8_string(&mut self) -> Result<Utf8String<'a>>
pub fn utf8_string(&mut self) -> Result<Utf8String<'a>>
Attempt to decode an ASN.1 UTF8String
.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Decoder<'a>
impl<'a> Send for Decoder<'a>
impl<'a> Sync for Decoder<'a>
impl<'a> Unpin for Decoder<'a>
impl<'a> UnwindSafe for Decoder<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more