Skip to main content

ImportSource

Trait ImportSource 

Source
pub trait ImportSource {
    // Required method
    fn next(&mut self) -> Result<Option<ImportedMemory>>;

    // Provided method
    fn size_hint(&self) -> Option<usize> { ... }
}
Expand description

Source of imported memories.

Implementations read memories from a specific format (JSON, YAML, CSV, etc.) and yield them one at a time for processing.

§Streaming

Sources should read data incrementally where possible to support large files without loading everything into memory.

§Example Implementation

impl ImportSource for JsonSource {
    fn next(&mut self) -> Result<Option<ImportedMemory>> {
        // Read next line, parse JSON, return memory
    }

    fn size_hint(&self) -> Option<usize> {
        None // Unknown for streaming
    }
}

Required Methods§

Source

fn next(&mut self) -> Result<Option<ImportedMemory>>

Reads the next memory from the source.

Returns Ok(None) when the source is exhausted.

§Errors

Returns an error if parsing fails or I/O errors occur.

Provided Methods§

Source

fn size_hint(&self) -> Option<usize>

Returns an estimate of the total number of records.

Used for progress reporting. Returns None if unknown.

Implementors§