Struct qldb::DocumentCollection[][src]

pub struct DocumentCollection { /* fields omitted */ }

Represents a collection of documents. It implements so you can call in order to use it in for loops or with .

It implements too.

It adds some utilities methods in order to do common operations.

You can use the into_iter in order to execute aggregate values or to make other complex operation.


use qldb::{DocumentCollection, QLDBExtractResult};

// Adds all the "points" attributes from each document.
// It stops early in case of error extracting the attribute.
fn count_points(matches: DocumentCollection) -> QLDBExtractResult<u64> {

    // You can use other types as BigUInt, BigDecimal, etc
    // in order to avoid overflow

    let result: u64 = matches
        .into_iter()
        .map(|doc| doc.get_value::<u64>("points"))
        .collect::<Result<Vec<u64>, _>>()?
        .into_iter()
        .fold(0, |acc, val| acc + val);

    Ok(result)
}

Implementations

impl DocumentCollection[src]

pub fn new(documents: Vec<Document>) -> DocumentCollection[src]

pub fn into_inner(self) -> Vec<Document>[src]

pub fn to_vec(self) -> Vec<Document>[src]

pub fn len(self) -> usize[src]

Trait Implementations

impl AsRef<Vec<Document, Global>> for DocumentCollection[src]

fn as_ref(&self) -> &Vec<Document>[src]

Performs the conversion.

impl Clone for DocumentCollection[src]

fn clone(&self) -> DocumentCollection[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for DocumentCollection[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for DocumentCollection[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl Extend<Document> for DocumentCollection[src]

fn extend<T: IntoIterator<Item = Document>>(&mut self, iter: T)[src]

Extends a collection with the contents of an iterator. Read more

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

impl Index<usize> for DocumentCollection[src]

type Output = Document

The returned type after indexing.

fn index(&self, index: usize) -> &Self::Output[src]

Performs the indexing (container[index]) operation. Read more

impl IntoIterator for DocumentCollection[src]

type Item = Document

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl PartialEq<DocumentCollection> for DocumentCollection[src]

fn eq(&self, other: &DocumentCollection) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &DocumentCollection) -> bool[src]

This method tests for !=.

impl TryFrom<Vec<IonValue, Global>> for DocumentCollection[src]

type Error = QLDBExtractError

The type returned in the event of a conversion error.

fn try_from(ion_values_vector: Vec<IonValue>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl StructuralPartialEq for DocumentCollection[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.