Skip to main content

StreamFormatDecode

Trait StreamFormatDecode 

Source
pub trait StreamFormatDecode<T>: StreamFormat {
    type Frame;
    type Framer: Decoder<Item = Self::Frame, Error = StreamError> + Send;
    type Parser: FrameParser<Self::Frame, T> + Send;

    // Required methods
    fn framer(&self, options: &DecodeOptions) -> Self::Framer;
    fn parser(&self) -> Self::Parser;
}
Expand description

Decodes bytes into items of type T.

Required Associated Types§

Source

type Frame

One framed record, before deserialisation.

Formats that can separate the two use a type independent of T, such as csv::ByteRecord, say. Formats that cannot use Result<T, StreamError> and an IdentityParser.

Source

type Framer: Decoder<Item = Self::Frame, Error = StreamError> + Send

Splits the body into records.

Its error type is the framing error, and it is terminal: FramedRead latches its error state and ends the stream. Correct, because a framer that has lost track of where records begin cannot resynchronise. Per-record deserialisation failures are not terminal and are reported by Self::Parser instead.

Source

type Parser: FrameParser<Self::Frame, T> + Send

Deserialises framed records.

Required Methods§

Source

fn framer(&self, options: &DecodeOptions) -> Self::Framer

Build a framer for one body.

Source

fn parser(&self) -> Self::Parser

Build a parser for one body.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl StreamFormatDecode<RecordBatch> for ArrowRecordBatchIpcStreamFormat

Available on crate feature arrow only.
Source§

impl<T, E> StreamFormatDecode<T> for JsonArrayStreamFormat<E>
where T: for<'de> Deserialize<'de>, E: Serialize,

Available on crate feature json only.
Source§

impl<T> StreamFormatDecode<T> for CsvStreamFormat
where T: for<'de> Deserialize<'de>,

Available on crate feature csv only.
Source§

impl<T> StreamFormatDecode<T> for JsonNewLineStreamFormat
where T: for<'de> Deserialize<'de>,

Available on crate feature json only.
Source§

impl<T> StreamFormatDecode<T> for ProtobufStreamFormat
where T: Message + Default,

Available on crate feature protobuf only.