pub trait ExternalChunk<T>: Sized + Iterator<Item = Result<T, Self::DeserializationError>> {
    type SerializationError: Error;
    type DeserializationError: Error;

    // Required methods
    fn new(reader: Take<BufReader<File>>) -> Self;
    fn dump(
        chunk_writer: &mut BufWriter<File>,
        items: impl IntoIterator<Item = T>
    ) -> Result<(), Self::SerializationError>;

    // Provided method
    fn build(
        dir: &TempDir,
        items: impl IntoIterator<Item = T>,
        buf_size: Option<usize>
    ) -> Result<Self, ExternalChunkError<Self::SerializationError>> { ... }
}
Expand description

External chunk interface. Provides methods for creating a chunk stored on file system and reading data from it.

Required Associated Types§

source

type SerializationError: Error

Error returned when data serialization failed.

source

type DeserializationError: Error

Error returned when data deserialization failed.

Required Methods§

source

fn new(reader: Take<BufReader<File>>) -> Self

Creates and instance of an external chunk.

Arguments
  • reader - The reader of the file the chunk is stored in
source

fn dump( chunk_writer: &mut BufWriter<File>, items: impl IntoIterator<Item = T> ) -> Result<(), Self::SerializationError>

Dumps items to an external file.

Arguments
  • chunk_writer - The writer of the file the data should be dumped in
  • items - Items to be dumped

Provided Methods§

source

fn build( dir: &TempDir, items: impl IntoIterator<Item = T>, buf_size: Option<usize> ) -> Result<Self, ExternalChunkError<Self::SerializationError>>

Builds an instance of an external chunk creating file and dumping the items to it.

Arguments
  • dir - Directory the chunk file is created in
  • items - Items to be dumped to the chunk
  • buf_size - File I/O buffer size

Implementors§