BulkInsert

Struct BulkInsert 

Source
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

Source

pub fn new(columns: Vec<BulkColumn>, batch_size: usize) -> Self

Create a new bulk insert operation.

Source

pub fn send_row<T: ToSql>(&mut self, values: &[T]) -> Result<(), Error>

Send a row of data.

The values must match the column order and types specified when creating the bulk insert.

§Errors

Returns an error if:

  • Wrong number of values provided
  • A value cannot be converted to the expected type
Source

pub fn send_row_values(&mut self, values: &[SqlValue]) -> Result<(), Error>

Send a row of pre-converted SQL values.

Source§

impl BulkInsert

Source

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).

Source

pub fn total_rows(&self) -> u64

Get total rows sent so far.

Source

pub fn rows_in_batch(&self) -> usize

Get rows in current batch.

Source

pub fn should_flush(&self) -> bool

Check if a batch flush is needed.

Source

pub fn finish_packets(&mut self) -> Vec<BytesMut>

Prepare for finishing the bulk operation. Writes the DONE token and returns final packets.

Source

pub fn result(&self) -> BulkInsertResult

Create a result from the current state.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more