pub struct CopyEncoder { /* private fields */ }Expand description
Encoder for COPY operations.
This encoder produces CopyData messages for PGCOPY binary, text, and CSV formats.
Implementations§
Source§impl CopyEncoder
impl CopyEncoder
Sourcepub fn new_binary(schema: Arc<Vec<FieldInfo>>) -> Self
pub fn new_binary(schema: Arc<Vec<FieldInfo>>) -> Self
Create a new binary format COPY encoder.
Sourcepub fn new_text(schema: Arc<Vec<FieldInfo>>, options: CopyTextOptions) -> Self
pub fn new_text(schema: Arc<Vec<FieldInfo>>, options: CopyTextOptions) -> Self
Create a new text format COPY encoder.
Sourcepub fn new_csv(schema: Arc<Vec<FieldInfo>>, options: CopyCsvOptions) -> Self
pub fn new_csv(schema: Arc<Vec<FieldInfo>>, options: CopyCsvOptions) -> Self
Create a new CSV format COPY encoder.
Sourcepub fn encode_field<T>(&mut self, value: &T) -> PgWireResult<()>
pub fn encode_field<T>(&mut self, value: &T) -> PgWireResult<()>
Encode a field value.
This method uses the type and format information from the schema.
Sourcepub fn take_copy(&mut self) -> CopyData
pub fn take_copy(&mut self) -> CopyData
Take the current row as a CopyData message.
For binary format: first call includes PGCOPY header. For text/CSV format: each call returns one row with a trailing newline.
Sourcepub fn finish_copy_binary() -> CopyData
pub fn finish_copy_binary() -> CopyData
Finish the COPY operation of binary format.
For binary format: returns trailer (-1).
Note that this trailer is automatically appended to stream if you use
CopyResponse API.
Auto Trait Implementations§
impl Freeze for CopyEncoder
impl RefUnwindSafe for CopyEncoder
impl Send for CopyEncoder
impl Sync for CopyEncoder
impl Unpin for CopyEncoder
impl UnwindSafe for CopyEncoder
Blanket Implementations§
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
Mutably borrows from an owned value. Read more