odbc_api::parameter

Trait CElement

Source
pub unsafe trait CElement: CData {
    // Required method
    fn assert_completness(&self);
}
Expand description

A CData representing a single value rather than an entire buffer of a range of values.

§Safety

Considerations for implementers

Callers must be able to rely on all pointers being valid, i.e. the “range” is not empty.

Since the indicator provided by implementation is used to indicate the length of the value in the buffer, care must be taken to prevent out of bounds access in case the implementation also is used as an output parameter, and contains truncated values (i.e. the indicator is longer than the buffer and the value within).

Required Methods§

Source

fn assert_completness(&self)

Must panic if the parameter is not complete. I.e. the indicator of a variable length parameter indicates a value larger than what is present in the value buffer.

This is used to prevent using truncacted values as input buffers, which could cause inserting invalid memory with drivers which just copy values for the length of the indicator buffer without checking the length of the target buffer first. The ODBC standard is inconclusive wether the driver has to check for this or not. So we need to check this. We can not manifest this as an invariant expressed by a type for all cases, due to the existence of input/output parameters.

Implementations on Foreign Types§

Source§

impl CElement for f32

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for f64

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for i8

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for i16

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for i32

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for i64

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for u8

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for u16

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for u32

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for u64

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for Box<dyn InputParameter>

Source§

impl CElement for CString

Source§

fn assert_completness(&self)

`CString`` is terminated by zero. Indicator can therefore never indicate a truncated value and is always complete.

Source§

impl CElement for CStr

Source§

fn assert_completness(&self)

CStr is terminated by zero. Indicator can therefore never indicate a truncated value and is always complete.

Source§

impl CElement for Date

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for Numeric

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for Time

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl CElement for Timestamp

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Implementors§

Source§

impl CElement for Bit

Source§

impl<K: VarKind> CElement for VarCell<&[K::Element], K>

Source§

impl<K: VarKind> CElement for VarCell<&mut [K::Element], K>

Source§

impl<K: VarKind> CElement for VarCell<Box<[K::Element]>, K>

Source§

impl<T> CElement for Nullable<T>
where T: Pod,

Source§

impl<T> CElement for WithDataType<T>
where T: CElement,

Source§

impl<const LENGTH: usize, K: VarKind> CElement for VarCell<[K::Element; LENGTH], K>