pub trait FrameBuilder {
type OwnedFrameType;
// Required methods
fn write_to<W: Write>(&self, writer: &mut W) -> Result<usize, Error>;
fn write_into(&self, into: &mut [u8]) -> Result<usize, Error>;
fn expected_size(&self) -> Option<usize>;
fn as_owned_frame(&self) -> Self::OwnedFrameType;
// Provided method
fn as_bytes(&self) -> Bytes { ... }
}Expand description
A frame builder can wrap another frame (or just data), and can be wrapped into another frame. The runtime hierarchy is the same as persisted.
Ex: Stored: SizedFrame(MultihashFrame(Data)) Runtime: SizedFrameBuilder(MultihashFrameBuilder(Data))
Required Associated Types§
type OwnedFrameType
Required Methods§
Sourcefn write_to<W: Write>(&self, writer: &mut W) -> Result<usize, Error>
fn write_to<W: Write>(&self, writer: &mut W) -> Result<usize, Error>
Write the frame to the given writer
Sourcefn write_into(&self, into: &mut [u8]) -> Result<usize, Error>
fn write_into(&self, into: &mut [u8]) -> Result<usize, Error>
Write the frame into the given bytes slice
Sourcefn expected_size(&self) -> Option<usize>
fn expected_size(&self) -> Option<usize>
Expected size of the frame (in bytes). Optional since some kind of frames have an unknown size until they are serialized (ex: capnp)
Sourcefn as_owned_frame(&self) -> Self::OwnedFrameType
fn as_owned_frame(&self) -> Self::OwnedFrameType
Creates a owned version of this frame, which is usually a FrameReader implementation
Provided Methods§
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.
Implementors§
Source§impl<A: FrameBuilder, B: FrameBuilder> FrameBuilder for CompoundFrameBuilder<A, B>
impl<A: FrameBuilder, B: FrameBuilder> FrameBuilder for CompoundFrameBuilder<A, B>
type OwnedFrameType = CompoundFrame<Bytes>
Source§impl<B: Buf> FrameBuilder for B
Implementation of FrameBuilder for a byte array allow wrapping the content
of the array into another frame
impl<B: Buf> FrameBuilder for B
Implementation of FrameBuilder for a byte array allow wrapping the content of the array into another frame