pub trait Decoder: Sized {
// Required methods
fn decode_byte(&mut self) -> Result<u8, DecodeError>;
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), DecodeError>;
// Provided methods
fn decode_ranged<T: Decode + PartialOrd>(
&mut self,
range: impl RangeBounds<T>,
) -> Result<T, DecodeError> { ... }
fn assert_magic(&mut self) -> Result<(), DecodeError> { ... }
fn decode<T: Decode>(&mut self) -> Result<T, DecodeError> { ... }
fn decode_trailing<T: Decode>(&mut self) -> Result<Option<T>, DecodeError> { ... }
fn decode_in<T: DecodeIn<A>, A: Allocator>(
&mut self,
alloc: A,
) -> Result<T, DecodeError> { ... }
}Expand description
Helper trait for reading OpenTimestamps primitives from a byte stream.
Required Methods§
Sourcefn decode_byte(&mut self) -> Result<u8, DecodeError>
fn decode_byte(&mut self) -> Result<u8, DecodeError>
Decodes a single byte from the reader.
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), DecodeError>
Provided Methods§
Sourcefn decode_ranged<T: Decode + PartialOrd>(
&mut self,
range: impl RangeBounds<T>,
) -> Result<T, DecodeError>
fn decode_ranged<T: Decode + PartialOrd>( &mut self, range: impl RangeBounds<T>, ) -> Result<T, DecodeError>
Decodes a value and ensures it falls within the supplied range.
Sourcefn assert_magic(&mut self) -> Result<(), DecodeError>
fn assert_magic(&mut self) -> Result<(), DecodeError>
Verifies that the next bytes in the stream match the magic sequence.
Sourcefn decode<T: Decode>(&mut self) -> Result<T, DecodeError>
fn decode<T: Decode>(&mut self) -> Result<T, DecodeError>
Decodes a value implementing the Decode trait.
Sourcefn decode_trailing<T: Decode>(&mut self) -> Result<Option<T>, DecodeError>
fn decode_trailing<T: Decode>(&mut self) -> Result<Option<T>, DecodeError>
Decodes a trailing optional value implementing the Decode trait.
See Decode::decode_trailing for details and caveats.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.