Skip to main content

Encoder

Trait Encoder 

Source
pub trait Encoder:
    Send
    + Sync
    + 'static {
    type Error: Error + Send + Sync + 'static;

    const EXT: &'static str;

    // Required method
    fn encode<R: Serialize + DeserializeOwned>(
        &self,
        records: &[R],
    ) -> Result<Vec<u8>, Self::Error>;
}
Expand description

Encodes one window of records into the bytes of a single file.

Implementations must succeed on an empty slice (a valid empty file), since callers may hand over drained-but-empty windows.

Required Associated Constants§

Source

const EXT: &'static str

File extension (no leading dot) for files this encoder produces, e.g. "parquet".

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Error produced when encoding fails.

Required Methods§

Source

fn encode<R: Serialize + DeserializeOwned>( &self, records: &[R], ) -> Result<Vec<u8>, Self::Error>

Encode records into an in-memory file.

§Errors

Returns the encoder’s error if serialization fails.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Encoder for JsonEncoder

Source§

const EXT: &'static str = "json"

Source§

type Error = Error

Source§

impl<C: ParquetCompression> Encoder for ParquetEncoder<C>

Available on crate feature parquet only.
Source§

const EXT: &'static str = "parquet"

Source§

type Error = ParquetEncodeError