Struct qldb::DocumentCollection[][src]

pub struct DocumentCollection { /* fields omitted */ }
Expand description

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

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

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

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

Extends a collection with exactly one element.

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

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

The returned type after indexing.

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Applies the Compat adapter by value. Read more

Applies the Compat adapter by shared reference. Read more

Applies the Compat adapter by mutable reference. Read more

Performs the conversion.

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

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

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.