odbc_api::buffers

Enum BufferDesc

Source
pub enum BufferDesc {
Show 14 variants Binary { length: usize, }, Text { max_str_len: usize, }, WText { max_str_len: usize, }, F64 { nullable: bool, }, F32 { nullable: bool, }, Date { nullable: bool, }, Time { nullable: bool, }, Timestamp { nullable: bool, }, I8 { nullable: bool, }, I16 { nullable: bool, }, I32 { nullable: bool, }, I64 { nullable: bool, }, U8 { nullable: bool, }, Bit { nullable: bool, },
}
Expand description

Describes a column of a crate::buffers::ColumnarBuffer.

While related to to the crate::DataType of the column this is bound to, the Buffer type is different as it does not describe the type of the data source but the format the data is going to be represented in memory. While the data source is often considered to choose the buffer type the kind of processing which is supposed to be applied to the data may be even more important if choosing the a buffer for the cursor type. E.g. if you intend to print a date to standard out it may be more reasonable to bind it as Text rather than Date.

Variants§

§

Binary

Variable sized binary buffer, holding up to length bytes per value.

Fields

§length: usize

Maximum number of bytes per value.

§

Text

Text buffer holding strings with binary length of up to max_str_len.

Consider an upper bound choosing this based on the information in a DataType::Varchar column. E.g. PostgreSQL may return a field size of several GiB for individual values if a column is specified as TEXT, or Microsoft SQL Server may return 0 for a column of type VARCHAR(max). In such situations, if values are truly that large, bulk fetching data is not recommended, but streaming individual fields one by one. Usually though, the actual cells of the table in the database contain much shorter values. The best thing todo is to adapt the database schema to better reflect the actual size of the values. Lacking control over the database schema, you can always choose a smaller buffer size than initializing the buffer in disagreement with the database schema.

Fields

§max_str_len: usize

Maximum string length. Terminating zero is excluded, i.e. memory for it will be implicitly allocated if required.

§

WText

UTF-16 encoded text buffer holding strings with length of up to max_str_len. Length is in terms of 2-Byte characters.

Fields

§max_str_len: usize

Maximum string length. Terminating zero is excluded, i.e. memory for it will be implicitly allocated if required.

§

F64

64 bit floating point

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

F32

32 bit floating point

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

Date

Describes a buffer holding crate::sys::Date values.

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

Time

Describes a buffer holding crate::sys::Time values.

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

Timestamp

Describes a buffer holding crate::sys::Timestamp values.

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

I8

Signed 8 Bit integer

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

I16

Signed 16 Bit integer

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

I32

Signed 32 Bit integer

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

I64

Signed 64 Bit integer

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

U8

Unsigned 8 Bit integer

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

§

Bit

Can either be zero or one

Fields

§nullable: bool

This indicates whether or not the buffer will be able to represent NULL values. This will cause an indicator buffer to be bound.

Implementations§

Source§

impl BufferDesc

Source

pub fn from_data_type(data_type: DataType, nullable: bool) -> Option<Self>

Source

pub fn bytes_per_row(&self) -> usize

Element size of buffer if bound as a columnar row. Can be used to estimate memory for columnar bindings.

Trait Implementations§

Source§

impl Clone for BufferDesc

Source§

fn clone(&self) -> BufferDesc

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 BufferDesc

Source§

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

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

impl PartialEq for BufferDesc

Source§

fn eq(&self, other: &BufferDesc) -> 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 Copy for BufferDesc

Source§

impl Eq for BufferDesc

Source§

impl StructuralPartialEq for BufferDesc

Auto Trait Implementations§

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