pub struct BLob(/* private fields */);Expand description
LOB implementation for binary values.
BLob is used within HdbValue::BLOB
instances received from the database.
Bigger LOBs are not transferred completely in the first roundtrip, instead more data is fetched in subsequent roundtrips when needed.
BLob respects the Connection’s lob read length
(see Connection::set_lob_read_length).
Implementations§
Source§impl BLob
impl BLob
Sourcepub async fn into_bytes(self) -> HdbResult<Vec<u8>>
pub async fn into_bytes(self) -> HdbResult<Vec<u8>>
Converts the BLob into a Vec
All outstanding data (data that were not yet fetched from the server) are fetched
into this BLob object,
before the complete data, as far as they were not yet read from this BLob object,
are returned.
§Example
let mut result_set = connection.query(query)?;
let mut blob = result_set.into_single_row()?.into_single_value()?.try_into_blob()?;
let b = blob.into_bytes()?; // Vec<u8>, can be huge§Alternative
For larger objects, a streaming approach using BLob::write_into
might by more appropriate, to avoid total allocation of the large object.
§Errors
Several variants of HdbError can occur.
Sourcepub async fn write_into<W: Unpin + AsyncWriteExt>(
self,
writer: &mut W,
) -> HdbResult<()>
pub async fn write_into<W: Unpin + AsyncWriteExt>( self, writer: &mut W, ) -> HdbResult<()>
Writes the content into the given writer.
Reads outstanding data in chunks of size
Connection::lob_read_length from the database
and writes them immediately into the writer,
thus avoiding that all data are materialized within this BLob.
§Errors
Various errors can occur.
Sourcepub async fn read_slice(
&mut self,
offset: u64,
length: u32,
) -> HdbResult<Vec<u8>>
pub async fn read_slice( &mut self, offset: u64, length: u32, ) -> HdbResult<Vec<u8>>
Reads from given offset and the given length, in bytes.
§Errors
Several variants of HdbError can occur.
Sourcepub fn total_byte_length(&self) -> u64
pub fn total_byte_length(&self) -> u64
Total length of data, in bytes.
Sourcepub fn cur_buf_len(&self) -> usize
pub fn cur_buf_len(&self) -> usize
Current size of the internal buffer, in bytes.
Sourcepub fn server_usage(&self) -> ServerUsage
pub fn server_usage(&self) -> ServerUsage
Provides information about the the server-side resource consumption that
is related to this BLob object.