pub struct VarBinary<B> { /* private fields */ }
Expand description

Binds a byte array as Variadic sized binary data. It can not be used for columnar bulk fetches, but if the buffer type is stack allocated it can be utilized in row wise bulk fetches.

Meaningful instantiations of this type are:

Implementations

Constructs a ‘missing’ value.

Create an instance from a Vec.

Creates a new instance from an existing buffer.

Valid payload of the buffer returned as slice or None in case the indicator is NULL_DATA.

Call this method to ensure that the entire field content did fit into the buffer. If you retrieve a field using crate::CursorRow::get_data, you can repeat the call until this method is false to read all the data.

use odbc_api::{CursorRow, parameter::VarBinaryArray, Error, handles::Statement};

fn process_large_binary<S: Statement>(
    col_index: u16,
    row: &mut CursorRow<S>
) -> Result<(), Error>{
    let mut buf = VarBinaryArray::<512>::NULL;
    row.get_data(col_index, &mut buf)?;
    while !buf.is_complete() {
        // Process bytes in stream without allocation. We can assume repeated calls to
        // get_data do not return `None` since it would have done so on the first call.
        process_slice(buf.as_bytes().unwrap());
    }
    Ok(())
}

fn process_slice(text: &[u8]) { /*...*/}

Read access to the underlying ODBC indicator. After data has been fetched the indicator value is set to the length the buffer should have had to hold the entire value. It may also be Indicator::Null to indicate NULL or Indicator::NoTotal which tells us the data source does not know how big the buffer must be to hold the complete value. Indicator::NoTotal implies that the content of the current buffer is valid up to its maximum capacity.

Call this method to reset the indicator to a value which matches the length returned by the Self::as_bytes method. This is useful if you want to insert values into the database despite the fact, that they might have been truncated.

Indicates missing data

Constructs a new instance containing the bytes in the specified buffer.

Indicates a missing value.

Construct from a slice. If value is longer than LENGTH it will be truncated.

Trait Implementations

The identifier of the C data type of the value buffer. When it is retrieving data from the data source with fetch, the driver converts the data to this type. When it sends data to the source, the driver converts the data from this type. Read more

Indicates the length of variable sized types. May be zero for fixed sized types. Used to determine the size or existence of input parameters. Read more

Pointer to a value corresponding to the one described by cdata_type.

Maximum length of the type in bytes (not characters). It is required to index values in bound buffers, if more than one parameter is bound. Can be set to zero for types not bound as parameter arrays, i.e. CStr. Read more

Indicates the length of variable sized types. May be zero for fixed sized types.

Pointer to a value corresponding to the one described by cdata_type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The SQL data as which the parameter is bound to ODBC.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.