odbc_api::parameter

Trait VarKind

Source
pub unsafe trait VarKind {
    type Element: Copy + Eq;

    const ZERO: Self::Element;
    const TERMINATING_ZEROES: usize;
    const C_DATA_TYPE: CDataType;

    // Required method
    fn relational_type(buffer_length: usize) -> DataType;
}
Expand description

A tag used to differentiate between different types of variadic buffers.

§Safety

  • Self::TERMINATING_ZEROES is used to calculate buffer offsets. The number of terminating zeroes is expressed in BufferElements.
  • Self::C_DATA_TYPE is used to bind parameters. Providing wrong values like e.g. a fixed length types, would cause even a correctly implemented odbc driver to access invalid memory.

Required Associated Constants§

Source

const ZERO: Self::Element

Zero for buffer element.

Source

const TERMINATING_ZEROES: usize

Number of terminating zeroes required for this kind of variadic buffer.

Source

const C_DATA_TYPE: CDataType

Required Associated Types§

Source

type Element: Copy + Eq

Either u8 for binary and narrow text or u16 for wide text. Wide text could also be represented as u8, after all everything is bytes. This makes it difficult though to create owned VarCell types from u16 buffers.

Required Methods§

Source

fn relational_type(buffer_length: usize) -> DataType

Relational type used to bind the parameter. buffer_length is specified in elements rather than bytes, if the two differ.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl VarKind for Binary

Source§

const ZERO: u8 = 0u8

Source§

const TERMINATING_ZEROES: usize = 0usize

Source§

const C_DATA_TYPE: CDataType = CDataType::Binary

Source§

type Element = u8

Source§

impl VarKind for Text

Source§

const ZERO: u8 = 0u8

Source§

const TERMINATING_ZEROES: usize = 1usize

Source§

const C_DATA_TYPE: CDataType = CDataType::Char

Source§

type Element = u8

Source§

impl VarKind for WideText

Source§

const ZERO: u16 = 0u16

Source§

const TERMINATING_ZEROES: usize = 1usize

Source§

const C_DATA_TYPE: CDataType = CDataType::WChar

Source§

type Element = u16