pub trait TopDecodeInput: Sized {
type NestedBuffer: NestedDecodeInput;
// Required methods
fn byte_len(&self) -> usize;
fn into_boxed_slice_u8(self) -> Box<[u8]>;
fn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>
where H: DecodeErrorHandler;
fn into_max_size_buffer_align_right<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<usize, H::HandledErr>
where H: DecodeErrorHandler;
fn into_nested_buffer(self) -> Self::NestedBuffer;
// Provided methods
fn into_u64<H>(self, h: H) -> Result<u64, H::HandledErr>
where H: DecodeErrorHandler { ... }
fn into_i64<H>(self, h: H) -> Result<i64, H::HandledErr>
where H: DecodeErrorHandler { ... }
fn supports_specialized_type<T: TryStaticCast>() -> bool { ... }
fn into_specialized<T, H>(self, h: H) -> Result<T, H::HandledErr>
where T: TryStaticCast,
H: DecodeErrorHandler { ... }
}
Expand description
Trait that abstracts away an underlying API for a top-level object deserializer. The underlying API can provide pre-parsed i64/u64 or pre-bundled boxed slices.
Required Associated Types§
Required Methods§
Sourcefn into_boxed_slice_u8(self) -> Box<[u8]>
fn into_boxed_slice_u8(self) -> Box<[u8]>
Provides the underlying data as an owned byte slice box. Consumes the input object in the process.
Sourcefn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>where
H: DecodeErrorHandler,
👎Deprecated since 0.48.1: Please use method into_max_size_buffer_align_right
instead.
fn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>where
H: DecodeErrorHandler,
into_max_size_buffer_align_right
instead.Puts the underlying data into a fixed size byte buffer and returns the populated data slice from this buffer.
Will return an error if the data exceeds the provided buffer.
Currently only kept for backwards compatibility.
Sourcefn into_max_size_buffer_align_right<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<usize, H::HandledErr>where
H: DecodeErrorHandler,
fn into_max_size_buffer_align_right<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<usize, H::HandledErr>where
H: DecodeErrorHandler,
Puts the underlying data into a fixed size byte buffer, aligned to the right.
This eases big endian decoding.
Returns the length of the original buffer.
fn into_nested_buffer(self) -> Self::NestedBuffer
Provided Methods§
Sourcefn into_u64<H>(self, h: H) -> Result<u64, H::HandledErr>where
H: DecodeErrorHandler,
fn into_u64<H>(self, h: H) -> Result<u64, H::HandledErr>where
H: DecodeErrorHandler,
Retrieves the underlying data as a pre-parsed u64. Expected to panic if the conversion is not possible.
Consumes the input object in the process.
Sourcefn into_i64<H>(self, h: H) -> Result<i64, H::HandledErr>where
H: DecodeErrorHandler,
fn into_i64<H>(self, h: H) -> Result<i64, H::HandledErr>where
H: DecodeErrorHandler,
Retrieves the underlying data as a pre-parsed i64. Expected to panic if the conversion is not possible.
Consumes the input object in the process.
fn supports_specialized_type<T: TryStaticCast>() -> bool
fn into_specialized<T, H>(self, h: H) -> Result<T, H::HandledErr>where
T: TryStaticCast,
H: DecodeErrorHandler,
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.
Implementations on Foreign Types§
Source§impl TopDecodeInput for Box<[u8]>
impl TopDecodeInput for Box<[u8]>
type NestedBuffer = OwnedBytesNestedDecodeInput
fn byte_len(&self) -> usize
fn into_boxed_slice_u8(self) -> Box<[u8]>
Source§fn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>where
H: DecodeErrorHandler,
fn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>where
H: DecodeErrorHandler,
into_max_size_buffer_align_right
instead.fn into_max_size_buffer_align_right<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<usize, H::HandledErr>where
H: DecodeErrorHandler,
fn into_nested_buffer(self) -> Self::NestedBuffer
Source§impl<'a> TopDecodeInput for &'a [u8]
impl<'a> TopDecodeInput for &'a [u8]
type NestedBuffer = &'a [u8]
fn byte_len(&self) -> usize
fn into_boxed_slice_u8(self) -> Box<[u8]>
Source§fn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>where
H: DecodeErrorHandler,
fn into_max_size_buffer<H, const MAX_LEN: usize>(
self,
buffer: &mut [u8; MAX_LEN],
h: H,
) -> Result<&[u8], H::HandledErr>where
H: DecodeErrorHandler,
into_max_size_buffer_align_right
instead.