Struct odbc_api::parameter::VarChar [−][src]
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]
B: BorrowMut<[u8]>,
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]
B: Default,
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]
B: Borrow<[u8]>,
fn cdata_type(&self) -> CDataType
[src]
fn indicator_ptr(&self) -> *const isize
[src]
fn value_ptr(&self) -> *const c_void
[src]
fn buffer_length(&self) -> isize
[src]
impl<B> CDataMut for VarChar<B> where
B: BorrowMut<[u8]>,
[src]
B: BorrowMut<[u8]>,
fn mut_indicator_ptr(&mut self) -> *mut isize
[src]
fn mut_value_ptr(&mut self) -> *mut c_void
[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]
B: Borrow<[u8]>,
impl<'a> InputParameter for VarChar<&'a [u8]>
[src]
Auto Trait Implementations
impl<B> RefUnwindSafe for VarChar<B> where
B: RefUnwindSafe,
B: RefUnwindSafe,
impl<B> Send for VarChar<B> where
B: Send,
B: Send,
impl<B> Sync for VarChar<B> where
B: Sync,
B: Sync,
impl<B> Unpin for VarChar<B> where
B: Unpin,
B: Unpin,
impl<B> UnwindSafe for VarChar<B> where
B: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,