Trait httpbis::solicit::frame::builder::FrameBuilder [] [src]

pub trait FrameBuilder: Write + Seek {
    fn write_header(&mut self, header: FrameHeader) -> Result<()> { ... }
    fn overwrite_header(&mut self, header: FrameHeader) -> Result<()> { ... }
    fn copy_bytes_from<R: Read>(&mut self, provider: &mut R) -> Result<u64>
    where
        Self: Sized
, { ... } fn write_padding(&mut self, padding_length: u8) -> Result<()> { ... } fn write_u32(&mut self, num: u32) -> Result<()> { ... } }

A trait that provides additional methods for serializing HTTP/2 frames.

All methods have a default implementation in terms of the io::Write API, but types can provide specialized more efficient implementations if possible. This is effectively a workaround for specialization not existing yet in Rust.

Provided Methods

Write the given frame header as the next octets (i.e. without moving the cursor to the beginning of the buffer).

Overwrite the previously written header, assuming it's the first byte sequence of the buffer.

The default implementation seeks to the beginning of the buffer, writes the header, and then moves the cursor back to its previos position (i.e. offset from the beginning).

Copy all available bytes from the given io::Read instance.

This method allows poor man's specialization for types that can implement the copy more efficiently than the io::copy function does (i.e. without the intermediate read into a stack-allocated buffer).

Write the given number of padding octets.

The default implementation invokes the underlying Writer's write method padding_length times.

Other FrameBuilder implementations could implement it more efficiently (e.g. if it is known that the FrameBuilder is backed by a zeroed buffer, there's no need to write anything, only increment a cursor/offset).

Write the given unsigned 32 bit integer to the underlying stream. The integer is written as four bytes in network endian style.

Implementors