Trait ed25519_dalek::pkcs8::spki::der::Reader
pub trait Reader<'r>: Sized {
Show 19 methods
// Required methods
fn input_len(&self) -> Length;
fn peek_byte(&self) -> Option<u8>;
fn peek_header(&self) -> Result<Header, Error>;
fn position(&self) -> Length;
fn read_slice(&mut self, len: Length) -> Result<&'r [u8], Error>;
// Provided methods
fn context_specific<T>(
&mut self,
tag_number: TagNumber,
tag_mode: TagMode
) -> Result<Option<T>, Error>
where T: DecodeValue<'r> + FixedTag { ... }
fn decode<T>(&mut self) -> Result<T, Error>
where T: Decode<'r> { ... }
fn error(&mut self, kind: ErrorKind) -> Error { ... }
fn finish<T>(self, value: T) -> Result<T, Error> { ... }
fn is_finished(&self) -> bool { ... }
fn offset(&self) -> Length { ... }
fn peek_tag(&self) -> Result<Tag, Error> { ... }
fn read_byte(&mut self) -> Result<u8, Error> { ... }
fn read_into<'o>(&mut self, buf: &'o mut [u8]) -> Result<&'o [u8], Error> { ... }
fn read_nested<'n, T, F>(
&'n mut self,
len: Length,
f: F
) -> Result<T, Error>
where F: FnOnce(&mut NestedReader<'n, Self>) -> Result<T, Error> { ... }
fn read_vec(&mut self, len: Length) -> Result<Vec<u8>, Error> { ... }
fn remaining_len(&self) -> Length { ... }
fn sequence<'n, F, T>(&'n mut self, f: F) -> Result<T, Error>
where F: FnOnce(&mut NestedReader<'n, Self>) -> Result<T, Error> { ... }
fn tlv_bytes(&mut self) -> Result<&'r [u8], Error> { ... }
}
pkcs8
only.Expand description
Reader trait which reads DER-encoded input.
Required Methods§
fn peek_header(&self) -> Result<Header, Error>
fn peek_header(&self) -> Result<Header, Error>
Peek forward in the input data, attempting to decode a Header
from
the data at the current position in the decoder.
Does not modify the decoder’s state.
fn read_slice(&mut self, len: Length) -> Result<&'r [u8], Error>
fn read_slice(&mut self, len: Length) -> Result<&'r [u8], Error>
Attempt to read data borrowed directly from the input as a slice, updating the internal cursor position.
§Returns
Ok(slice)
on successErr(ErrorKind::Incomplete)
if there is not enough dataErr(ErrorKind::Reader)
if the reader can’t borrow from the input
Provided Methods§
fn context_specific<T>(
&mut self,
tag_number: TagNumber,
tag_mode: TagMode
) -> Result<Option<T>, Error>where
T: DecodeValue<'r> + FixedTag,
fn context_specific<T>(
&mut self,
tag_number: TagNumber,
tag_mode: TagMode
) -> Result<Option<T>, Error>where
T: DecodeValue<'r> + FixedTag,
Attempt to decode an ASN.1 CONTEXT-SPECIFIC
field with the
provided TagNumber
.
fn decode<T>(&mut self) -> Result<T, Error>where
T: Decode<'r>,
fn decode<T>(&mut self) -> Result<T, Error>where
T: Decode<'r>,
Decode a value which impls the Decode
trait.
fn error(&mut self, kind: ErrorKind) -> Error
fn error(&mut self, kind: ErrorKind) -> Error
Return an error with the given ErrorKind
, annotating it with
context about where the error occurred.
fn finish<T>(self, value: T) -> Result<T, Error>
fn finish<T>(self, value: T) -> Result<T, Error>
Finish decoding, returning the given value if there is no remaining data, or an error otherwise
fn is_finished(&self) -> bool
fn is_finished(&self) -> bool
Have we read all of the input data?
fn offset(&self) -> Length
fn offset(&self) -> Length
Offset within the original input stream.
This is used for error reporting, and doesn’t need to be overridden
by any reader implementations (except for the built-in NestedReader
,
which consumes nested input messages)
fn peek_tag(&self) -> Result<Tag, Error>
fn peek_tag(&self) -> Result<Tag, Error>
Peek at the next byte in the decoder and attempt to decode it as a
Tag
value.
Does not modify the decoder’s state.
fn read_into<'o>(&mut self, buf: &'o mut [u8]) -> Result<&'o [u8], Error>
fn read_into<'o>(&mut self, buf: &'o mut [u8]) -> Result<&'o [u8], Error>
Attempt to read input data, writing it into the provided buffer, and returning a slice on success.
§Returns
Ok(slice)
if there is sufficient dataErr(ErrorKind::Incomplete)
if there is not enough data
fn read_nested<'n, T, F>(&'n mut self, len: Length, f: F) -> Result<T, Error>
fn read_nested<'n, T, F>(&'n mut self, len: Length, f: F) -> Result<T, Error>
Read nested data of the given length.
fn read_vec(&mut self, len: Length) -> Result<Vec<u8>, Error>
fn read_vec(&mut self, len: Length) -> Result<Vec<u8>, Error>
alloc
only.Read a byte vector of the given length.
fn remaining_len(&self) -> Length
fn remaining_len(&self) -> Length
Get the number of bytes still remaining in the buffer.
Object Safety§
Implementors§
impl<'a> Reader<'a> for SliceReader<'a>
impl<'i> Reader<'i> for PemReader<'i>
pem
only.