Skip to main content

CollationKeySink

Trait CollationKeySink 

Source
pub trait CollationKeySink {
    type Error;
    type State;
    type Output;

    // Required methods
    fn write(
        &mut self,
        state: &mut Self::State,
        buf: &[u8],
    ) -> Result<(), Self::Error>;
    fn finish(
        &mut self,
        state: Self::State,
    ) -> Result<Self::Output, Self::Error>;

    // Provided method
    fn write_byte(
        &mut self,
        state: &mut Self::State,
        b: u8,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

A std::io::Write-like trait for writing to a buffer-like object.

(This crate does not have access to std.)

๐Ÿšง This code is considered unstable; it may change at any time, in breaking or non-breaking ways, including in SemVer minor releases. Do not implement or call methods on this trait unless you are prepared for things to occasionally break.

Graduation tracking issue: issue #7178.

โœจ Enabled with the unstable Cargo feature.

Required Associated Typesยง

Source

type Error

The type of error the sink may return.

Source

type State

An intermediate state object used by the sink, which must implement Default.

Source

type Output

A result value indicating the final state of the sink (e.g. a number of bytes written).

Required Methodsยง

Source

fn write( &mut self, state: &mut Self::State, buf: &[u8], ) -> Result<(), Self::Error>

Writes a buffer into the writer.

Source

fn finish(&mut self, state: Self::State) -> Result<Self::Output, Self::Error>

Finalize any internal sink state (perhaps by flushing a buffer) and return the final output value.

Provided Methodsยง

Source

fn write_byte( &mut self, state: &mut Self::State, b: u8, ) -> Result<(), Self::Error>

Write a single byte into the writer.

Implementations on Foreign Typesยง

Sourceยง

impl CollationKeySink for VecDeque<u8>

Sourceยง

type Error = Infallible

Sourceยง

type State = ()

Sourceยง

type Output = ()

Sourceยง

fn write(&mut self, _: &mut Self::State, buf: &[u8]) -> Result<(), Self::Error>

Sourceยง

fn finish(&mut self, _: Self::State) -> Result<Self::Output, Self::Error>

Sourceยง

impl CollationKeySink for Vec<u8>

Sourceยง

type Error = Infallible

Sourceยง

type State = ()

Sourceยง

type Output = ()

Sourceยง

fn write(&mut self, _: &mut Self::State, buf: &[u8]) -> Result<(), Self::Error>

Sourceยง

fn finish(&mut self, _: Self::State) -> Result<Self::Output, Self::Error>

Sourceยง

impl CollationKeySink for [u8]

Sourceยง

type Error = TooSmall

Sourceยง

type State = usize

Sourceยง

type Output = usize

Sourceยง

fn write( &mut self, offset: &mut Self::State, buf: &[u8], ) -> Result<(), Self::Error>

Sourceยง

fn finish(&mut self, offset: Self::State) -> Result<Self::Output, Self::Error>

Sourceยง

impl<const N: usize> CollationKeySink for SmallVec<[u8; N]>

Sourceยง

type Error = Infallible

Sourceยง

type State = ()

Sourceยง

type Output = ()

Sourceยง

fn write(&mut self, _: &mut Self::State, buf: &[u8]) -> Result<(), Self::Error>

Sourceยง

fn finish(&mut self, _: Self::State) -> Result<Self::Output, Self::Error>

Implementorsยง