[][src]Struct hdbconnect::types::NCLob

pub struct NCLob(_);

LOB implementation for unicode Strings that is used with HdbValue::NCLOB instances coming from the database.

Bigger LOBs are not transferred completely in the first roundtrip, instead more data are fetched in subsequent roundtrips when they are needed.

NCLob respects the Connection's lob read length (see Connection::set_lob_read_length), by transferring per fetch request lob_read_length unicode characters (rather than bytes). Note that due to the way how HANA represents unicode internally, all BMP-0 characters count as 1, non-BMP-0 characters count as 2.

Implementations

impl NCLob[src]

pub fn into_string(self) -> HdbResult<String>[src]

Converts the NCLob into the contained String.

All outstanding data (data that were not yet fetched from the server) are fetched into this NCLob object, before the complete data, as far as they were not yet read from this NCLob object, are returned.

Example

 let mut resultset = connection.query(query)?;
 let mut nclob = resultset.into_single_row()?.into_single_value()?.try_into_nclob()?;
 let s = nclob.into_string(); // String, can be huge

Alternative

For larger objects, a streaming approach using the Read implementation of NCLob might by more appropriate, to avoid total allocation of the large object.

Example

 let mut writer;
 // ... writer gets instantiated, is an implementation of std::io::Write;

 std::io::copy(&mut nclob, &mut writer)?;

Errors

Several variants of HdbError can occur.

pub fn read_slice(
    &mut self,
    offset: u64,
    length: u32
) -> HdbResult<CharLobSlice>
[src]

Reads from given offset and the given length, in number of unicode characters.

Note that due to the way how HANA represents unicode internally, all BMP-0 characters count as 1, non-BMP-0 characters count as 2.

Errors

Several variants of HdbError can occur.

pub fn total_byte_length(&self) -> u64[src]

Total length of data, in bytes.

pub fn total_char_length(&self) -> u64[src]

Total length of data, in characters.

Note that due to the way how HANA represents unicode internally, all BMP-0 characters count as 1, non-BMP-0 characters count as 2.

pub fn is_empty(&self) -> bool[src]

Returns true if the NCLob does not contain data.

pub fn max_buf_len(&self) -> usize[src]

Returns the maximum size the internal buffers ever had, in bytes.

This method exists mainly for debugging purposes. With streaming, the returned value is not supposed to exceed 3 times lob_read_length (see Connection::set_lob_read_length) plus the buffer size used by the reader.

pub fn cur_buf_len(&self) -> usize[src]

Current size of the internal buffer, in bytes.

pub fn server_usage(&self) -> ServerUsage[src]

Provides information about the the server-side resource consumption that is related to this NCBLob object.

Trait Implementations

impl Clone for NCLob[src]

impl Debug for NCLob[src]

impl Read for NCLob[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<R> ReadBytesExt for R where
    R: Read + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,