odbc_api::buffers

Struct TextColumnSliceMut

Source
pub struct TextColumnSliceMut<'a, C> { /* private fields */ }
Expand description

A view to a mutable array parameter text buffer, which allows for filling the buffer with values.

Implementations§

Source§

impl<'a, C> TextColumnSliceMut<'a, C>
where C: Default + Copy,

Source

pub fn set_cell(&mut self, row_index: usize, element: Option<&[C]>)

Sets the value of the buffer at index at Null or the specified binary Text. This method will panic on out of bounds index, or if input holds a text which is larger than the maximum allowed element length. element must be specified without the terminating zero.

Source

pub fn ensure_max_element_length( &mut self, element_length: usize, num_rows_to_copy: usize, ) -> Result<(), Error>

Ensures that the buffer is large enough to hold elements of element_length. Does nothing if the buffer is already large enough. Otherwise it will reallocate and rebind the buffer. The first num_rows_to_copy_elements will be copied from the old value buffer to the new one. This makes this an extremely expensive operation.

Source

pub fn set_mut(&mut self, index: usize, length: usize) -> &mut [C]

Can be used to set a value at a specific row index without performing a memcopy on an input slice and instead provides direct access to the underlying buffer.

In situations there the memcopy can not be avoided anyway Self::set_cell is likely to be more convenient. This method is very useful if you want to write! a string value to the buffer and the binary (!) length of the formatted string is known upfront.

§Example: Write timestamp to text column.
use odbc_api::buffers::TextColumnSliceMut;
use std::io::Write;

/// Writes times formatted as hh::mm::ss.fff
fn write_time(
    col: &mut TextColumnSliceMut<u8>,
    index: usize,
    hours: u8,
    minutes: u8,
    seconds: u8,
    milliseconds: u16)
{
    write!(
        col.set_mut(index, 12),
        "{:02}:{:02}:{:02}.{:03}",
        hours, minutes, seconds, milliseconds
    ).unwrap();
}

Auto Trait Implementations§

§

impl<'a, C> Freeze for TextColumnSliceMut<'a, C>

§

impl<'a, C> RefUnwindSafe for TextColumnSliceMut<'a, C>
where C: RefUnwindSafe,

§

impl<'a, C> !Send for TextColumnSliceMut<'a, C>

§

impl<'a, C> !Sync for TextColumnSliceMut<'a, C>

§

impl<'a, C> Unpin for TextColumnSliceMut<'a, C>

§

impl<'a, C> !UnwindSafe for TextColumnSliceMut<'a, C>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more