laminar-derive
Derive macros for LaminarDB -- Record, FromRecordBatch, FromRow, and ConnectorConfig.
Overview
Procedural macros for Arrow RecordBatch conversion and connector config parsing. Eliminates the boilerplate of writing to_record_batch() / from_batch() by hand.
Macros
#[derive(Record)]
Generates Record::schema(), Record::to_record_batch(), and Record::event_time() for typed data ingestion.
use Record;
Attributes:
#[event_time]-- marks a field as the event time column#[column("name")]-- overrides the Arrow column name#[nullable]-- marks a non-Option field as nullable in the schema
Supported types: bool, i8-i64, u8-u64, f32, f64, String, Vec<u8>, Option<T>
#[derive(FromRecordBatch)]
Generates from_batch() and from_batch_all() for deserializing Arrow RecordBatches into typed structs. Fields are matched by name.
use FromRecordBatch;
#[derive(FromRow)]
Like FromRecordBatch, but also implements laminar_db::FromBatch. Fields are matched by position (column order in SELECT), not by name.
use FromRow;
#[derive(ConnectorConfig)]
Generates from_config(), validate(), and config_keys() for connector configuration parsing.
use ConnectorConfig;
Attributes:
#[config(key = "...")]-- config key name#[config(required)]-- field is required#[config(default = "...")]-- default value#[config(env = "...")]-- environment variable fallback#[config(description = "...")]-- documentation for the key#[config(duration_ms)]-- parse asDurationfrom milliseconds
Related Crates
laminar-core--Recordtrait definitionlaminar-db--TypedSubscription<T>andSourceHandle<T>that use derived traitslaminar-connectors-- Connector SDK that usesConnectorConfig