Struct odbc_api::buffers::NullableSliceMut
source · pub struct NullableSliceMut<'a, T> { /* private fields */ }Expand description
Used to fill a column buffer with an iterator. Returned by
crate::ColumnarBulkInserter::column_mut as part of an crate::buffers::AnySliceMut.
Implementations§
source§impl<'a, T> NullableSliceMut<'a, T>
impl<'a, T> NullableSliceMut<'a, T>
sourcepub fn set_cell(&mut self, index: usize, cell: Option<T>)
pub fn set_cell(&mut self, index: usize, cell: Option<T>)
Sets the value at the specified index. Use None to specify a NULL value.
sourcepub fn raw_values(&mut self) -> (&mut [T], &mut [isize])
pub fn raw_values(&mut self) -> (&mut [T], &mut [isize])
Write access to the underlying raw value and indicator buffer.
The number of elements in the buffer is equal to len.
This method is useful for writing performant bindings to datastructures with similar binary layout, as it allows for using memcopy rather than iterating over individual values.
Example
use odbc_api::{buffers::NullableSliceMut, sys::NULL_DATA};
// Memcopy the values into the buffer, and set indicators according to mask
// values.
fn copy_values_and_make_mask(
new_values: &[i32],
mask: &[bool],
odbc_slice: &mut NullableSliceMut<i32>)
{
let (values, indicators) = odbc_slice.raw_values();
values.copy_from_slice(new_values);
// Create array of bools indicating null values.
indicators.iter_mut().zip(mask.iter()).for_each(|(indicator, &mask)| {
*indicator = if mask {
0
} else {
NULL_DATA
}
});
}Trait Implementations§
Auto Trait Implementations§
impl<'a, T> RefUnwindSafe for NullableSliceMut<'a, T>where T: RefUnwindSafe,
impl<'a, T> Send for NullableSliceMut<'a, T>where T: Send,
impl<'a, T> Sync for NullableSliceMut<'a, T>where T: Sync,
impl<'a, T> Unpin for NullableSliceMut<'a, T>
impl<'a, T> !UnwindSafe for NullableSliceMut<'a, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more