[][src]Struct qldb::DocumentCollection

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]

impl Clone for DocumentCollection[src]

impl Debug for DocumentCollection[src]

impl Default for DocumentCollection[src]

impl Extend<Document> for DocumentCollection[src]

impl Index<usize> for DocumentCollection[src]

type Output = Document

The returned type after indexing.

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?

impl PartialEq<DocumentCollection> for DocumentCollection[src]

impl StructuralPartialEq for DocumentCollection[src]

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

type Error = QLDBExtractError

The type returned in the event of a conversion error.

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> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.