Struct odbc_api::parameter::VarBinary[][src]

pub struct VarBinary<B> { /* fields omitted */ }
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

impl VarBinary<Box<[u8], Global>>[src]

pub fn null() -> Self[src]

Constructs a ‘missing’ value.

pub fn from_vec(val: Vec<u8>) -> Self[src]

Create an instance from a Vec.

impl<B> VarBinary<B> where
    B: Borrow<[u8]>, 
[src]

pub fn from_buffer(buffer: B, indicator: Indicator) -> Self[src]

Creates a new instance from an existing buffer.

pub fn as_bytes(&self) -> Option<&[u8]>[src]

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

pub fn is_complete(&self) -> bool[src]

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]) { /*...*/}

pub fn indicator(&self) -> Indicator[src]

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.

impl<B> VarBinary<B> where
    B: Borrow<[u8]>, 
[src]

pub fn hide_truncation(&mut self)[src]

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.

impl<'a> VarBinary<&'a [u8]>[src]

pub const NULL: Self[src]

Indicates missing data

pub fn new(value: &'a [u8]) -> Self[src]

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

impl<const LENGTH: usize> VarBinary<[u8; LENGTH]>[src]

pub const NULL: Self[src]

Indicates a missing value.

pub fn new(bytes: &[u8]) -> Self[src]

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

Trait Implementations

impl<B> CData for VarBinary<B> where
    B: Borrow<[u8]>, 
[src]

fn cdata_type(&self) -> CDataType[src]

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

fn indicator_ptr(&self) -> *const isize[src]

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

fn value_ptr(&self) -> *const c_void[src]

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

fn buffer_length(&self) -> isize[src]

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

impl<B> CDataMut for VarBinary<B> where
    B: BorrowMut<[u8]>, 
[src]

fn mut_indicator_ptr(&mut self) -> *mut isize[src]

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

fn mut_value_ptr(&mut self) -> *mut c_void[src]

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

impl<B: Clone> Clone for VarBinary<B>[src]

fn clone(&self) -> VarBinary<B>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<B: Debug> Debug for VarBinary<B>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<B> HasDataType for VarBinary<B> where
    B: Borrow<[u8]>, 
[src]

fn data_type(&self) -> DataType[src]

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

impl<B: Copy> Copy for VarBinary<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for VarBinary<B> where
    B: RefUnwindSafe

impl<B> Send for VarBinary<B> where
    B: Send

impl<B> Sync for VarBinary<B> where
    B: Sync

impl<B> Unpin for VarBinary<B> where
    B: Unpin

impl<B> UnwindSafe for VarBinary<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.