Skip to main content

CatalogWriter

Trait CatalogWriter 

Source
pub trait CatalogWriter: Debug + Send {
    // Required methods
    fn write_instruments(&mut self, instruments: &[InstrumentAny]) -> Result<()>;
    fn write_data(
        &mut self,
        data: &[Data],
        start: Option<UnixNanos>,
        end: Option<UnixNanos>,
        params: Option<Params>,
    ) -> Result<()>;
    fn write_records(
        &mut self,
        record_type: NautilusRecordType,
        batches: &[RecordBatch],
        params: Option<Params>,
    ) -> Result<()>;
    fn record_empty_coverage(
        &mut self,
        data_type: NautilusDataType,
        identifier: Option<&str>,
        start: UnixNanos,
        end: UnixNanos,
    ) -> Result<()>;

    // Provided method
    fn write_data_batch(
        &mut self,
        batch: &DataBatch,
        start: Option<UnixNanos>,
        end: Option<UnixNanos>,
        params: Option<Params>,
    ) -> Result<()> { ... }
}
Expand description

Runtime catalog mutation API.

Implementations must preserve the typed logical schema of built-in data, records, and instruments. Only user-defined [Data::Custom] values may use an opaque, self-describing payload.

Required Methods§

Source

fn write_instruments(&mut self, instruments: &[InstrumentAny]) -> Result<()>

Writes instrument definitions into the catalog.

Backends must preserve typed instrument fields rather than storing an opaque serialized instrument payload.

§Errors

Returns an error if the backend write fails.

Source

fn write_data( &mut self, data: &[Data], start: Option<UnixNanos>, end: Option<UnixNanos>, params: Option<Params>, ) -> Result<()>

Writes mixed built-in data values into the catalog.

Pass a non-empty data vec. To record coverage for a known-empty interval, use Self::record_empty_coverage instead. Backends must preserve the fixed schema of built-in variants. An opaque, self-describing payload is permitted only for user-defined [Data::Custom] values.

§Errors

Returns an error if the backend write fails.

Source

fn write_records( &mut self, record_type: NautilusRecordType, batches: &[RecordBatch], params: Option<Params>, ) -> Result<()>

Writes Arrow record batches for a record family into the catalog.

Backends must preserve the fixed schema selected by [NautilusRecordType] rather than storing an opaque serialized payload.

§Errors

Returns an error if the backend cannot persist the record batches.

Source

fn record_empty_coverage( &mut self, data_type: NautilusDataType, identifier: Option<&str>, start: UnixNanos, end: UnixNanos, ) -> Result<()>

Records request coverage for a known-empty interval.

Backends may do nothing when the interval is not adjacent to an existing file.

§Errors

Returns an error if the backend cannot record empty coverage.

Provided Methods§

Source

fn write_data_batch( &mut self, batch: &DataBatch, start: Option<UnixNanos>, end: Option<UnixNanos>, params: Option<Params>, ) -> Result<()>

Writes a typed data batch into the catalog.

Implementations can override this to avoid materializing compatibility [Data] rows.

§Errors

Returns an error if the backend write fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§