pub trait FrameReader {
type OwnedType: FrameReader;
// Required methods
fn exposed_data(&self) -> &[u8] ⓘ;
fn whole_data(&self) -> &[u8] ⓘ;
fn to_owned_frame(&self) -> Self::OwnedType;
// Provided methods
fn whole_data_size(&self) -> usize { ... }
fn copy_to<W: Write>(&self, writer: &mut W) -> Result<(), Error> { ... }
fn copy_into(&self, into: &mut [u8]) -> Result<usize, Error> { ... }
}Expand description
Represents a frame that either wrap another frame or bytes (vec or slice).
The hierarchy of a FrameReader instances are the opposite of the persisted hierarchy. Ex: Stored: SizedFrame( MultihashFrame( Data ) ) Runtime: Data ( MultiHash ( SizedFrame ) )
The reason for this reversal is that the inner most frame doesn’t know how to extract the bytes from the whole frame. Therefor, the wrapping frame “exposes” the bytes to the inner most frames at runtime.
Required Associated Types§
type OwnedType: FrameReader
Required Methods§
Sourcefn exposed_data(&self) -> &[u8] ⓘ
fn exposed_data(&self) -> &[u8] ⓘ
Data exposed by this frame to inner frame. Ex: sized frame will expose the sized data without encoded size numbers
Sourcefn whole_data(&self) -> &[u8] ⓘ
fn whole_data(&self) -> &[u8] ⓘ
Data of the whole frame, not just the exposed data.
Sourcefn to_owned_frame(&self) -> Self::OwnedType
fn to_owned_frame(&self) -> Self::OwnedType
Converts the frame to a owned version (without lifetime)
Provided Methods§
Sourcefn whole_data_size(&self) -> usize
fn whole_data_size(&self) -> usize
Size of the whole data of the frame.
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.