Enum odbc_api::buffers::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.
Text
Fields
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.
WText
Fields
UTF-16 encoded text buffer holding strings with length of up to max_str_len
. Length is in
terms of 2-Byte characters.
F64
Fields
64 bit floating point
F32
Fields
32 bit floating point
Date
Fields
Describes a buffer holding crate::sys::Date
values.
Time
Fields
Describes a buffer holding crate::sys::Time
values.
Timestamp
Fields
Describes a buffer holding crate::sys::Timestamp
values.
I8
Fields
Signed 8 Bit integer
I16
Fields
Signed 16 Bit integer
I32
Fields
Signed 32 Bit integer
I64
Fields
Signed 64 Bit integer
U8
Fields
Unsigned 8 Bit integer
Bit
Fields
Can either be zero or one
Implementations§
source§impl BufferDesc
impl BufferDesc
pub fn from_data_type(data_type: DataType, nullable: bool) -> Option<Self>
sourcepub fn bytes_per_row(&self) -> usize
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
impl Clone for BufferDesc
source§fn clone(&self) -> BufferDesc
fn clone(&self) -> BufferDesc
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more