Struct odbc_api::parameter::WithDataType[][src]

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 = unsafe {
    Environment::new()?
};

let mut conn = env.connect("YourDatabase", "SA", "<YourStrong@Passw0rd>")?;
// 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

impl<T> CData for WithDataType<T> where
    T: CData
[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<T> HasDataType for WithDataType<T> where
    T: HasDataType
[src]

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

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

impl<T> InputParameter for WithDataType<T> where
    T: InputParameter
[src]

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

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, 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.