Struct odbc_api::parameter::VarChar[][src]

pub struct VarChar<B> { /* fields omitted */ }

A mutable buffer for character data which can be used as either input parameter or ouput buffer. It can not be used for columar bulk fetches, but if the buffer type is stack allocated in can be utilized in row wise bulk fetches.

This type is very similar to self::VarCharRef and indeed it can perform many of the same tasks, since self::VarCharRef is exclusive used as an input parameter though it must not account for a terminating zero at the end of the buffer.

Implementations

impl<B> VarChar<B> where
    B: BorrowMut<[u8]>, 
[src]

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

Creates a new instance. It takes ownership of the buffer. The indicator tells us up to which position the buffer is filled. Pass None for the indicator to create a value representing NULL. The constructor will write a terminating zero after the end of the valid sequence in the buffer.

pub fn copy_from_bytes(bytes: Option<&[u8]>) -> Self where
    B: Default
[src]

Construct a new VarChar and copy the value of the slice into the internal buffer. None indicates NULL.

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

Returns the binary representation of the string, excluding the terminating zero.

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::VarChar512, Error, handles::Statement};

fn process_large_text<S: Statement>(
    col_index: u16,
    row: &mut CursorRow<S>
) -> Result<(), Error>{
    let mut buf = VarChar512::from_buffer([0;512], None);
    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_text_slice(buf.as_bytes().unwrap());
    }
    Ok(())
}

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

pub fn indicator(&self) -> isize[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, excluding the terminating zere. It may also be NULL_DATA to indicate NULL or NO_TOTAL which tells us the data source does not know how big the buffer must be to hold the complete value. NO_TOTAL implies that the content of the current buffer is valid up to its maximum capacity.

Trait Implementations

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

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

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

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

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

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

impl<'a> InputParameter for VarChar<&'a [u8]>[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.