Struct odbc_api::TooLargeBufferSize
source · Expand description
Error indicating a failed allocation for a column buffer
Fields§
§num_elements: usizeNumber of elements supposed to be in the buffer.
element_size: usizeElement size in the buffer in bytes.
Implementations§
source§impl TooLargeBufferSize
impl TooLargeBufferSize
sourcepub fn add_context(self, buffer_index: u16) -> Error
pub fn add_context(self, buffer_index: u16) -> Error
Map the column allocation error to an crate::Error adding the context of which
column caused the allocation error.
Examples found in repository?
src/buffers/any_buffer.rs (line 311)
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) })
}More examples
src/buffers/columnar.rs (line 335)
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
pub fn from_max_str_lens(
row_capacity: usize,
max_str_lengths: impl IntoIterator<Item = usize>,
) -> Result<Self, Error> {
let buffers = max_str_lengths
.into_iter()
.enumerate()
.map(|(index, max_str_len)| {
Ok((
(index + 1).try_into().unwrap(),
TextColumn::try_new(row_capacity, max_str_len)
.map_err(|source| source.add_context(index.try_into().unwrap()))?,
))
})
.collect::<Result<_, _>>()?;
Ok(TextRowSet {
row_capacity,
num_rows: Box::new(0),
columns: buffers,
})
}