odbc_api

Struct Bit

Source
pub struct Bit(pub u8);
Expand description

New type wrapping u8 and binding as SQL_BIT.

If rust would guarantee the representation of bool to be an u8, bool would be the obvious choice instead. Alas it is not and someday on some platform bool might be something else than a u8 so let’s use this new type instead.

Tuple Fields§

§0: u8

Implementations§

Source§

impl Bit

Source

pub fn from_bool(boolean: bool) -> Self

Maps true to 1 and false to 0.

use odbc_api::Bit;

assert_eq!(Bit(0), Bit::from_bool(false));
assert_eq!(Bit(1), Bit::from_bool(true));
Source

pub fn as_bool(self) -> bool

Maps 1 to true, 0 to false. Panics if Bit should be invalid (not 0 or 1).

Trait Implementations§

Source§

impl CData for Bit

Source§

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.
Source§

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.
Source§

fn value_ptr(&self) -> *const c_void

Pointer to a value corresponding to the one described by cdata_type.
Source§

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.
Source§

impl CDataMut for Bit

Source§

fn mut_indicator_ptr(&mut self) -> *mut isize

Indicates the length of variable sized types. May be zero for fixed sized types.

Source§

fn mut_value_ptr(&mut self) -> *mut c_void

Pointer to a value corresponding to the one described by cdata_type.

Source§

impl CElement for Bit

Source§

fn assert_completness(&self)

Fixed sized types are always complete

Source§

impl Clone for Bit

Source§

fn clone(&self) -> Bit

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Bit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Bit

Source§

fn default() -> Bit

Returns the “default value” for a type. Read more
Source§

impl FetchRowMember for Bit

Source§

fn indicator(&self) -> Option<Indicator>

Indicator for variable sized or nullable types, None for fixed sized types.
Source§

fn find_truncation(&self, buffer_index: usize) -> Option<TruncationInfo>

Some if the indicator indicates truncation. Always None for fixed sized types.
Source§

unsafe fn bind_to_col( &mut self, col_index: u16, cursor: &mut StatementRef<'_>, ) -> Result<(), Error>

Bind row element to column. Only called for the first row in a row wise buffer. Read more
Source§

impl HasDataType for Bit

Source§

fn data_type(&self) -> DataType

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

impl Item for Bit

Source§

fn buffer_desc(nullable: bool) -> BufferDesc

Can be used to instantiate a super::ColumnarBuffer. This is useful to allocate the correct buffers in generic code. Read more
Source§

fn as_slice(variant: AnySlice<'_>) -> Option<&[Self]>

Extract the array type from an AnySlice.
Source§

fn as_nullable_slice(variant: AnySlice<'_>) -> Option<NullableSlice<'_, Self>>

Extract the typed nullable buffer from an AnySlice.
Source§

fn as_slice_mut(variant: AnySliceMut<'_>) -> Option<&mut [Self]>

Extract the array type from an AnySliceMut.
Source§

fn as_nullable_slice_mut( variant: AnySliceMut<'_>, ) -> Option<NullableSliceMut<'_, Self>>

Extract the typed nullable buffer from an AnySliceMut.
Source§

impl Ord for Bit

Source§

fn cmp(&self, other: &Bit) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Bit

Source§

fn eq(&self, other: &Bit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Bit

Source§

fn partial_cmp(&self, other: &Bit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Bit

Source§

impl Eq for Bit

Source§

impl OutputParameter for Bit

Source§

impl StructuralPartialEq for Bit

Auto Trait Implementations§

§

impl Freeze for Bit

§

impl RefUnwindSafe for Bit

§

impl Send for Bit

§

impl Sync for Bit

§

impl Unpin for Bit

§

impl UnwindSafe for Bit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoParameter for T
where T: InputParameter,

Source§

impl<T> ParameterCollection for T
where T: InputParameterCollection + ?Sized,

Source§

fn parameter_set_size(&self) -> usize

Number of values per parameter in the collection. This can be different from the maximum batch size a buffer may be able to hold. Returning 0 will cause the the query not to be executed.
Source§

unsafe fn bind_parameters_to( &mut self, stmt: &mut impl Statement, ) -> Result<(), Error>

Bind the parameters to a statement Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> InputParameter for T
where T: CElement + HasDataType,