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§
Sourcefn assert_completness(&self)
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
impl CElement for f32
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for f64
impl CElement for f64
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for i16
impl CElement for i16
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for i32
impl CElement for i32
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for i64
impl CElement for i64
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for u16
impl CElement for u16
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for u32
impl CElement for u32
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for u64
impl CElement for u64
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for Box<dyn InputParameter>
impl CElement for Box<dyn InputParameter>
fn assert_completness(&self)
Source§impl CElement for CString
impl CElement for CString
Source§fn assert_completness(&self)
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
impl CElement for CStr
Source§fn assert_completness(&self)
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
impl CElement for Date
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for Numeric
impl CElement for Numeric
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for Time
impl CElement for Time
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete
Source§impl CElement for Timestamp
impl CElement for Timestamp
Source§fn assert_completness(&self)
fn assert_completness(&self)
Fixed sized types are always complete