pub(super) trait CopyInCodec:
Send
+ Sync
+ Debug {
// Required methods
fn name(&self) -> &'static str;
fn check_column_type(
&self,
data_type: &ConcreteDataType,
) -> PgWireResult<()>;
fn create_parser(
&self,
columns: &[ColumnSchema],
timezone: &str,
) -> PgWireResult<Box<dyn RecordParser + Send>>;
// Provided method
fn format_code(&self) -> i8 { ... }
}Expand description
A COPY FROM STDIN data format implementation.
Implementations are shared per statement (hence Send + Sync) and must
be stateless; per-stream state belongs to the RecordParser they
create. Every method is tailored to the format: check_column_type
declares the types the format can decode (csv is bounded by what
arrow-csv supports).
Required Methods§
Sourcefn check_column_type(&self, data_type: &ConcreteDataType) -> PgWireResult<()>
fn check_column_type(&self, data_type: &ConcreteDataType) -> PgWireResult<()>
Validates that a column of data_type can be ingested by this
format.
Sourcefn create_parser(
&self,
columns: &[ColumnSchema],
timezone: &str,
) -> PgWireResult<Box<dyn RecordParser + Send>>
fn create_parser( &self, columns: &[ColumnSchema], timezone: &str, ) -> PgWireResult<Box<dyn RecordParser + Send>>
Creates the stateful parser for one copy stream over the targeted columns (in COPY field order).
timezone is the session timezone (an IANA name or a UTC offset):
formats that parse offset-free timestamp strings from text should
interpret them in this zone, matching SQL INSERT.
Provided Methods§
Sourcefn format_code(&self) -> i8
fn format_code(&self) -> i8
The format code advertised in the CopyInResponse header: 0 when
the client sends textual data (the default), 1 for binary.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".