Struct odbc_api::parameter::WithDataType
source · [−]pub struct WithDataType<T> {
pub value: T,
pub data_type: DataType,
}
Expand description
Annotates an instance of an inner type with an SQL Data type in order to indicate how it should be bound as a parameter to an SQL Statement.
Example
use odbc_api::{Environment, parameter::WithDataType, DataType};
let env = Environment::new()?;
let mut conn = env.connect("YourDatabase", "SA", "My@Test@Password1")?;
// Bind year as VARCHAR(4) rather than integer.
let year = WithDataType{
value: 1980,
data_type: DataType::Varchar {length: 4}
};
if let Some(cursor) = conn.execute("SELECT year, name FROM Birthdays WHERE year > ?;", &year)? {
// Use cursor to process query results.
}
Fields
value: T
Value to wrap with a Data Type. Should implement crate::handles::CData
, to be useful.
data_type: DataType
The SQL type this value is supposed to map onto. What exactly happens with this information is up to the ODBC driver in use.
Trait Implementations
sourceimpl<T> CData for WithDataType<T> where
T: CData,
impl<T> CData for WithDataType<T> where
T: CData,
sourcefn cdata_type(&self) -> CDataType
fn cdata_type(&self) -> CDataType
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
sourcefn indicator_ptr(&self) -> *const isize
fn indicator_ptr(&self) -> *const isize
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
sourcefn value_ptr(&self) -> *const c_void
fn value_ptr(&self) -> *const c_void
Pointer to a value corresponding to the one described by cdata_type
.
sourcefn buffer_length(&self) -> isize
fn buffer_length(&self) -> isize
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
sourceimpl<T> CDataMut for WithDataType<T> where
T: CDataMut,
impl<T> CDataMut for WithDataType<T> where
T: CDataMut,
sourcefn mut_indicator_ptr(&mut self) -> *mut isize
fn mut_indicator_ptr(&mut self) -> *mut isize
Indicates the length of variable sized types. May be zero for fixed sized types.
sourcefn mut_value_ptr(&mut self) -> *mut c_void
fn mut_value_ptr(&mut self) -> *mut c_void
Pointer to a value corresponding to the one described by cdata_type
.
sourceimpl<T> ColumnBuffer for WithDataType<T> where
T: ColumnBuffer,
impl<T> ColumnBuffer for WithDataType<T> where
T: ColumnBuffer,
sourcefn view(&self, valid_rows: usize) -> <T as ColumnProjections<'_>>::View
fn view(&self, valid_rows: usize) -> <T as ColumnProjections<'_>>::View
Num rows may not exceed the actually amount of valid num_rows filled be the ODBC API. The column buffer does not know how many elements were in the last row group, and therefore can not guarantee the accessed element to be valid and in a defined state. It also can not panic on accessing an undefined element. Read more
sourceunsafe fn view_mut(
&mut self,
valid_rows: usize
) -> <T as ColumnProjections<'_>>::ViewMut
unsafe fn view_mut(
&mut self,
valid_rows: usize
) -> <T as ColumnProjections<'_>>::ViewMut
Safety Read more
sourcefn fill_default(&mut self, from: usize, to: usize)
fn fill_default(&mut self, from: usize, to: usize)
Fills the column with the default representation of values, between from
and to
index.
sourceimpl<'a, T> ColumnProjections<'a> for WithDataType<T> where
T: ColumnProjections<'a>,
impl<'a, T> ColumnProjections<'a> for WithDataType<T> where
T: ColumnProjections<'a>,
sourceimpl<T> HasDataType for WithDataType<T> where
T: HasDataType,
impl<T> HasDataType for WithDataType<T> where
T: HasDataType,
impl<T> InputParameter for WithDataType<T> where
T: InputParameter,
Auto Trait Implementations
impl<T> RefUnwindSafe for WithDataType<T> where
T: RefUnwindSafe,
impl<T> Send for WithDataType<T> where
T: Send,
impl<T> Sync for WithDataType<T> where
T: Sync,
impl<T> Unpin for WithDataType<T> where
T: Unpin,
impl<T> UnwindSafe for WithDataType<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more