pub struct CopyParser<'a> { /* private fields */ }Expand description
Parser for PostgreSQL COPY data blocks
Implementations§
Source§impl<'a> CopyParser<'a>
impl<'a> CopyParser<'a>
Sourcepub fn with_schema(self, schema: &'a TableSchema) -> Self
pub fn with_schema(self, schema: &'a TableSchema) -> Self
Set the table schema for PK/FK extraction
Sourcepub fn with_extraction(self, extraction: RowExtraction) -> Self
pub fn with_extraction(self, extraction: RowExtraction) -> Self
Choose how much per-row derived data to compute (default: RowExtraction::Full).
Sourcepub fn with_column_order(self, columns: Vec<String>) -> Self
pub fn with_column_order(self, columns: Vec<String>) -> Self
Set column order from the COPY header. Resolution against the schema is
deferred to parse_rows, so this may be called before with_schema.
Sourcepub fn parse_rows(&mut self) -> Result<Vec<ParsedCopyRow>>
pub fn parse_rows(&mut self) -> Result<Vec<ParsedCopyRow>>
Parse all rows from the COPY data block, collecting them into a Vec.
A thin collecting adapter over CopyParser::parse_rows_visit.
Sourcepub fn parse_rows_visit<F>(&mut self, f: F) -> Result<()>
pub fn parse_rows_visit<F>(&mut self, f: F) -> Result<()>
Stream each parsed COPY row to f without collecting a block-sized
Vec. f returns a RowFlow to stop early.
Sourcepub fn prepared(self) -> (Self, bool)
pub fn prepared(self) -> (Self, bool)
Finish column-context setup and report whether an empty line counts as a
row, for the Parser::visit_events single-line streaming path.
Sourcepub fn parse_line(
&self,
line: &[u8],
empty_line_is_row: bool,
) -> Option<ParsedCopyRow>
pub fn parse_line( &self, line: &[u8], empty_line_is_row: bool, ) -> Option<ParsedCopyRow>
Parse a single raw COPY data line (as delivered by
crate::parser::ParserEvent::CopyRow). Strips a trailing \r, and
returns None for a skippable blank line or the \. terminator, exactly
matching CopyParser::parse_rows_visit. Requires CopyParser::prepared
to have been called first.
Sourcepub fn decode_copy_escapes(&self, value: &[u8]) -> Vec<u8> ⓘ
pub fn decode_copy_escapes(&self, value: &[u8]) -> Vec<u8> ⓘ
Decode PostgreSQL COPY escape sequences.
Thin wrapper kept for API compatibility; the implementation lives in
the free function decode_copy_escapes.
Auto Trait Implementations§
impl<'a> Freeze for CopyParser<'a>
impl<'a> RefUnwindSafe for CopyParser<'a>
impl<'a> Send for CopyParser<'a>
impl<'a> Sync for CopyParser<'a>
impl<'a> Unpin for CopyParser<'a>
impl<'a> UnsafeUnpin for CopyParser<'a>
impl<'a> UnwindSafe for CopyParser<'a>
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more