pub struct BinaryCopyEncoder { /* private fields */ }Expand description
Encoder for binary COPY IN format.
Builds a buffer containing the binary header, tuple data, and trailer.
§Example
use sentinel_driver::copy::binary::BinaryCopyEncoder;
let mut encoder = BinaryCopyEncoder::new();
// Write a row with two columns: int4(42) and text("hello")
encoder.begin_row(2);
encoder.write_field(&42i32.to_be_bytes());
encoder.write_field(b"hello");
// Write another row with a NULL second column
encoder.begin_row(2);
encoder.write_field(&7i32.to_be_bytes());
encoder.write_null();
let data = encoder.finish();
// data can be sent via CopyIn::write_raw()Implementations§
Source§impl BinaryCopyEncoder
impl BinaryCopyEncoder
pub fn new() -> Self
Sourcepub fn write_field(&mut self, data: &[u8])
pub fn write_field(&mut self, data: &[u8])
Write a non-NULL field value (already in binary PG format).
Sourcepub fn write_null(&mut self)
pub fn write_null(&mut self)
Write a NULL field.
Sourcepub fn finish(self) -> Vec<u8> ⓘ
pub fn finish(self) -> Vec<u8> ⓘ
Finish encoding and return the complete binary COPY data.
Appends the trailer (field_count = -1).
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BinaryCopyEncoder
impl RefUnwindSafe for BinaryCopyEncoder
impl Send for BinaryCopyEncoder
impl Sync for BinaryCopyEncoder
impl Unpin for BinaryCopyEncoder
impl UnsafeUnpin for BinaryCopyEncoder
impl UnwindSafe for BinaryCopyEncoder
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