pub struct BulkInsert { /* private fields */ }Expand description
Active bulk insert operation.
This struct manages the streaming of row data to the server.
Call send_row() for each row, then finish() to complete.
Implementations§
Source§impl BulkInsert
impl BulkInsert
Sourcepub fn new(columns: Vec<BulkColumn>, batch_size: usize) -> Self
pub fn new(columns: Vec<BulkColumn>, batch_size: usize) -> Self
Create a new bulk insert operation.
Sourcepub fn new_with_server_metadata(
columns: Vec<BulkColumn>,
batch_size: usize,
raw_colmetadata: Option<Bytes>,
server_columns: Option<&[ColumnData]>,
) -> Self
pub fn new_with_server_metadata( columns: Vec<BulkColumn>, batch_size: usize, raw_colmetadata: Option<Bytes>, server_columns: Option<&[ColumnData]>, ) -> Self
Create a new bulk insert operation using server metadata.
When raw_colmetadata is provided, it is written directly into the
BulkLoad buffer, ensuring the COLMETADATA matches the server’s exact
encoding. server_columns provides per-column type info so row values
are encoded correctly (fixed-length types have no length prefix).
This follows the pattern used by Tiberius: the server’s own metadata
from SELECT TOP 0 is echoed back rather than constructing it from
user-specified types.
Source§impl BulkInsert
impl BulkInsert
Sourcepub fn take_packets(&mut self) -> Vec<BytesMut>
pub fn take_packets(&mut self) -> Vec<BytesMut>
Get the buffered data as packets ready to send.
Returns a vector of complete TDS packets with BulkLoad packet type (0x07).
Sourcepub fn total_rows(&self) -> u64
pub fn total_rows(&self) -> u64
Get total rows sent so far.
Sourcepub fn rows_in_batch(&self) -> usize
pub fn rows_in_batch(&self) -> usize
Get rows in current batch.
Sourcepub fn should_flush(&self) -> bool
pub fn should_flush(&self) -> bool
Check if a batch flush is needed.
Note: BulkWriter does not consult this — it buffers every row and
sends one batch on finish. This is a helper for callers driving the
lower-level BulkInsert packet API manually.
Sourcepub fn finish_packets(&mut self) -> Vec<BytesMut>
pub fn finish_packets(&mut self) -> Vec<BytesMut>
Prepare for finishing the bulk operation. Writes the DONE token and returns final packets.
Sourcepub fn result(&self) -> BulkInsertResult
pub fn result(&self) -> BulkInsertResult
Create a result from the current state.