pub struct QueryResultItem { /* private fields */ }
Expand description

Represents a single match of a DQL query, similar to a “row” in SQL terms. It’s a reference type serving as a “cursor”, allowing for efficient access of the underlying data in various formats.

The row is lazily materialized and kept in memory until it goes out of scope. To reduce the memory footprint, access the items using the provided iterator.

let cars: Vec<Car> = all_cars_query_result
    .iter()
    .map(|query_result_item| query_result_item.deserialize_value().unwrap())
    .collect();

Implementations§

source§

impl QueryResultItem

source

pub fn value(&self) -> Arc<HashMap<Box<str>, Value>>

Returns the content as a materialized object.

The item’s value is .materialize()-ed on first access and subsequently on each access after performing .dematerialize(). Once materialized, the value is kept in memory until explicitly .dematerialize()-ed or the item goes out of scope.

source

pub fn is_materialized(&self) -> bool

Returns true if value is currently held materialized in memory, otherwise returns false.

See Also
source

pub fn materialize(&mut self)

Loads the CBOR representation of the item’s content, decodes it as a dictionary so it can be accessed via .value(). Keeps the dictionary in memory until .dematerialize() is called. No-op if value is already materialized.

source

pub fn dematerialize(&mut self)

Releases the materialized value from memory. No-op if item is not materialized.

source

pub fn cbor_data(&self) -> Vec<u8>

Return the content of the item as a CBOR slice.

Important: The returned CBOR slice is not cached, make sure to call this method once and keep it for as long as needed.

source

pub fn json_string(&self) -> String

Return the content of the item as a JSON string.

Important: The returned JSON string is not cached, make sure to call this method once and keep it for as long as needed.

source

pub fn deserialize_value<T: DeserializeOwned>(&self) -> Result<T, DittoError>

Convenience around Self::cbor_data() deserialize-ing the value.

Important: The returned value is not cached, make sure to call this method once and keep it for as long as needed.

Trait Implementations§

source§

impl From<Box<QueryResultItem>> for QueryResultItem

source§

fn from(raw: Box<QueryResultItem>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

impl<T> To for Twhere T: ?Sized,

§

fn to<T>(self) -> Twhere Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V