Skip to main content

FormatAdapter

Trait FormatAdapter 

Source
pub trait FormatAdapter {
    // Required methods
    fn name(&self) -> &str;
    fn entities(
        &mut self,
    ) -> impl Iterator<Item = Result<EntityRecord, AdapterError>>;
    fn edges(
        &mut self,
    ) -> impl Iterator<Item = Result<EdgeRecord, AdapterError>>;
    fn warnings(&self) -> &[String];
}
Expand description

A format adapter for the KG import pipeline.

Implementations parse a source format and yield entity and edge records using the standard EntityRecord/EdgeRecord wire shapes. The adapter writes no database state — its output is consumed by the standard khive kg import pipeline.

Each iterator item is Ok(record) on success or Err(AdapterError) on a per-record parse failure. Non-fatal issues (unknown optional fields, etc.) accumulate internally and are retrievable via FormatAdapter::warnings. Parsing may be eager or lazy depending on the implementation.

Required Methods§

Source

fn name(&self) -> &str

Short name of the format handled by this adapter (e.g. "csv", "json").

Source

fn entities( &mut self, ) -> impl Iterator<Item = Result<EntityRecord, AdapterError>>

Iterate over entity records in the source.

Source

fn edges(&mut self) -> impl Iterator<Item = Result<EdgeRecord, AdapterError>>

Iterate over edge records in the source.

Source

fn warnings(&self) -> &[String]

Non-fatal warnings accumulated during parsing (e.g. unknown columns, missing optional fields).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§