Struct odbc_api::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 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 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<'a>(variant: AnySliceMut<'a>) -> Option<&'a mut [Self]>

Extract the array type from an AnySliceMut.
source§

fn as_nullable_slice_mut<'a>( variant: AnySliceMut<'a> ) -> Option<NullableSliceMut<'a, 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) -> Selfwhere Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl PartialEq<Bit> for Bit

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Bit> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl CElement for Bit

source§

impl Copy for Bit

source§

impl Eq for Bit

source§

impl OutputParameter for Bit

source§

impl StructuralEq for Bit

source§

impl StructuralPartialEq for Bit

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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