pub trait Streamable:
Schema
+ Sized
+ Send {
type Row: Row;
// Required method
fn rows(self) -> impl Iterator<Item = Self::Row> + Send;
// Provided methods
fn stream<'life0, 'async_trait>(
self,
client: &'life0 Client,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn finalize<'life0, 'async_trait>(
client: &'life0 Client,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Bulk data upload via PostgreSQL’s binary COPY protocol.
Enables high-throughput streaming of domain objects to the database using PostgreSQL’s most efficient data ingestion path. The binary format avoids text parsing overhead and matches Rust’s native types.
§Requirements
Implementors must also implement Schema for table metadata and
define a Row type that handles binary serialization.
§Performance
Binary COPY is orders of magnitude faster than INSERT statements for bulk loading. A typical clustering run uploads millions of rows in seconds rather than hours.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn stream<'life0, 'async_trait>(
self,
client: &'life0 Client,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
self,
client: &'life0 Client,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Streams all rows to PostgreSQL via binary COPY.
Opens a COPY stream, writes each row in binary format, and
finalizes the upload. Consumes self to enable move semantics.
Sourcefn finalize<'life0, 'async_trait>(
client: &'life0 Client,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn finalize<'life0, 'async_trait>(
client: &'life0 Client,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Creates indices and optimizes table for read-heavy access.
Call once after all data has been uploaded. Creates indices
defined by Schema::indices and applies freeze settings.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.