pub enum AnyBuffer {
Show 25 variants
Binary(BinColumn),
Text(CharColumn),
WText(WCharColumn),
Date(Vec<Date>),
Time(Vec<Time>),
Timestamp(Vec<Timestamp>),
F64(Vec<f64>),
F32(Vec<f32>),
I8(Vec<i8>),
I16(Vec<i16>),
I32(Vec<i32>),
I64(Vec<i64>),
U8(Vec<u8>),
Bit(Vec<Bit>),
NullableDate(ColumnWithIndicator<Date>),
NullableTime(ColumnWithIndicator<Time>),
NullableTimestamp(ColumnWithIndicator<Timestamp>),
NullableF64(ColumnWithIndicator<f64>),
NullableF32(ColumnWithIndicator<f32>),
NullableI8(ColumnWithIndicator<i8>),
NullableI16(ColumnWithIndicator<i16>),
NullableI32(ColumnWithIndicator<i32>),
NullableI64(ColumnWithIndicator<i64>),
NullableU8(ColumnWithIndicator<u8>),
NullableBit(ColumnWithIndicator<Bit>),
}Expand description
Buffer holding a single column of either a result set or paramater
Variants§
Binary(BinColumn)
A buffer for holding both nullable and required binary data.
Text(CharColumn)
A buffer for holding both nullable and required text data. Uses the system encoding for character data.
WText(WCharColumn)
A buffer for holding both nullable and required text data. Uses UTF-16 encoding
Date(Vec<Date>)
Time(Vec<Time>)
Timestamp(Vec<Timestamp>)
F64(Vec<f64>)
F32(Vec<f32>)
I8(Vec<i8>)
I16(Vec<i16>)
I32(Vec<i32>)
I64(Vec<i64>)
U8(Vec<u8>)
Bit(Vec<Bit>)
NullableDate(ColumnWithIndicator<Date>)
NullableTime(ColumnWithIndicator<Time>)
NullableTimestamp(ColumnWithIndicator<Timestamp>)
NullableF64(ColumnWithIndicator<f64>)
NullableF32(ColumnWithIndicator<f32>)
NullableI8(ColumnWithIndicator<i8>)
NullableI16(ColumnWithIndicator<i16>)
NullableI32(ColumnWithIndicator<i32>)
NullableI64(ColumnWithIndicator<i64>)
NullableU8(ColumnWithIndicator<u8>)
NullableBit(ColumnWithIndicator<Bit>)
Implementations§
source§impl AnyBuffer
impl AnyBuffer
sourcepub fn try_from_desc(
max_rows: usize,
desc: BufferDesc
) -> Result<Self, TooLargeBufferSize>
pub fn try_from_desc(
max_rows: usize,
desc: BufferDesc
) -> Result<Self, TooLargeBufferSize>
Map buffer description to actual buffer.
Examples found in repository?
src/buffers/any_buffer.rs (line 310)
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
pub fn try_from_descs(
capacity: usize,
descs: impl IntoIterator<Item = BufferDesc>,
) -> Result<Self, Error> {
let mut column_index = 0;
let columns = descs
.into_iter()
.map(move |desc| {
let buffer = AnyBuffer::try_from_desc(capacity, desc)
.map_err(|source| source.add_context(column_index))?;
column_index += 1;
Ok((column_index, buffer))
})
.collect::<Result<_, _>>()?;
Ok(unsafe { ColumnarBuffer::new_unchecked(capacity, columns) })
}sourcepub fn from_desc(max_rows: usize, desc: BufferDesc) -> Self
pub fn from_desc(max_rows: usize, desc: BufferDesc) -> Self
Map buffer description to actual buffer.
Examples found in repository?
src/prepared.rs (line 229)
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
pub fn into_column_inserter(
self,
capacity: usize,
descriptions: impl IntoIterator<Item = BufferDesc>,
) -> Result<ColumnarBulkInserter<S, AnyBuffer>, Error> {
let parameter_buffers = descriptions
.into_iter()
.map(|desc| AnyBuffer::from_desc(capacity, desc))
.collect();
unsafe { self.unchecked_bind_columnar_array_parameters(parameter_buffers) }
}
/// A [`crate::ColumnarBulkInserter`] which has ownership of the bound array parameter buffers
/// and borrows the statement. For most usecases [`Self::into_any_column_inserter`] is what you
/// want to use, yet on some instances you may want to bind new paramater buffers to the same
/// prepared statement. E.g. to grow the capacity dynamicaly during insertions with several
/// chunks. In such usecases you may only want to borrow the prepared statemnt, so it can be
/// reused with a different set of parameter buffers.
pub fn column_inserter(
&mut self,
capacity: usize,
descriptions: impl IntoIterator<Item = BufferDesc>,
) -> Result<ColumnarBulkInserter<StatementRef<'_>, AnyBuffer>, Error> {
let stmt = self.statement.as_stmt_ref();
let parameter_buffers = descriptions
.into_iter()
.map(|desc| AnyBuffer::from_desc(capacity, desc))
.collect();
unsafe { ColumnarBulkInserter::new(stmt, parameter_buffers) }
}More examples
src/buffers/any_buffer.rs (line 290)
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
pub fn from_descs(capacity: usize, descs: impl IntoIterator<Item = BufferDesc>) -> Self {
let mut column_index = 0;
let columns = descs
.into_iter()
.map(move |desc| {
let buffer = AnyBuffer::from_desc(capacity, desc);
column_index += 1;
(column_index, buffer)
})
.collect();
unsafe { ColumnarBuffer::new_unchecked(capacity, columns) }
}
/// Allocates a [`ColumnarBuffer`] fitting the buffer descriptions. If not enough memory is
/// available to allocate the buffers this function fails with
/// [`Error::TooLargeColumnBufferSize`]. This function is slower than [`Self::from_description`]
/// which would just panic if not enough memory is available for allocation.
pub fn try_from_descs(
capacity: usize,
descs: impl IntoIterator<Item = BufferDesc>,
) -> Result<Self, Error> {
let mut column_index = 0;
let columns = descs
.into_iter()
.map(move |desc| {
let buffer = AnyBuffer::try_from_desc(capacity, desc)
.map_err(|source| source.add_context(column_index))?;
column_index += 1;
Ok((column_index, buffer))
})
.collect::<Result<_, _>>()?;
Ok(unsafe { ColumnarBuffer::new_unchecked(capacity, columns) })
}
/// Allows you to pass the buffer descriptions together with a one based column index referring
/// the column, the buffer is supposed to bind to. This allows you also to ignore columns in a
/// result set, by not binding them at all. There is no restriction on the order of column
/// indices passed, but the function will panic, if the indices are not unique.
pub fn from_descs_and_indices(
max_rows: usize,
description: impl Iterator<Item = (u16, BufferDesc)>,
) -> ColumnarBuffer<AnyBuffer> {
let columns: Vec<_> = description
.map(|(col_index, buffer_desc)| {
(col_index, AnyBuffer::from_desc(max_rows, buffer_desc))
})
.collect();
// Assert uniqueness of indices
let mut indices = HashSet::new();
if columns
.iter()
.any(move |&(col_index, _)| !indices.insert(col_index))
{
panic!("Column indices must be unique.")
}
ColumnarBuffer::new(columns)
}Trait Implementations§
source§impl<'a> BoundInputSlice<'a> for AnyBuffer
impl<'a> BoundInputSlice<'a> for AnyBuffer
§type SliceMut = AnySliceMut<'a>
type SliceMut = AnySliceMut<'a>
Intended to allow for modifying buffer contents, while leaving the bound parameter buffers
valid.
source§unsafe fn as_view_mut(
&'a mut self,
parameter_index: u16,
stmt: StatementRef<'a>
) -> Self::SliceMut
unsafe fn as_view_mut(
&'a mut self,
parameter_index: u16,
stmt: StatementRef<'a>
) -> Self::SliceMut
Obtain a mutable view on a parameter buffer in order to change the parameter value(s)
submitted when executing the statement. Read more
source§impl CData for AnyBuffer
impl CData for AnyBuffer
source§fn cdata_type(&self) -> CDataType
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
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
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
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 AnyBuffer
impl CDataMut for AnyBuffer
source§fn mut_indicator_ptr(&mut self) -> *mut isize
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
fn mut_value_ptr(&mut self) -> *mut c_void
Pointer to a value corresponding to the one described by
cdata_type.source§impl ColumnBuffer for AnyBuffer
impl ColumnBuffer for AnyBuffer
source§fn fill_default(&mut self, from: usize, to: usize)
fn fill_default(&mut self, from: usize, to: usize)
Fills the column with the default representation of values, between from and to index.
§type View<'a> = AnySlice<'a>
type View<'a> = AnySlice<'a>
Immutable view on the column data. Used in safe abstractions. User must not be able to
access uninitialized or invalid memory of the buffer through this interface.
source§fn view(&self, valid_rows: usize) -> AnySlice<'_>
fn view(&self, valid_rows: usize) -> AnySlice<'_>
Num rows may not exceed the actually amount of valid num_rows filled be the ODBC API. The
column buffer does not know how many elements were in the last row group, and therefore can
not guarantee the accessed element to be valid and in a defined state. It also can not panic
on accessing an undefined element.