Struct qldb::DocumentCollection
source · [−]pub struct DocumentCollection { /* private fields */ }Expand description
Represents a collection of documents. It implements so you can call in order to use it in for loops or with .
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
sourceimpl Clone for DocumentCollection
impl Clone for DocumentCollection
sourcefn clone(&self) -> DocumentCollection
fn clone(&self) -> DocumentCollection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for DocumentCollection
impl Debug for DocumentCollection
sourceimpl Default for DocumentCollection
impl Default for DocumentCollection
sourceimpl Extend<Document> for DocumentCollection
impl Extend<Document> for DocumentCollection
sourcefn extend<T: IntoIterator<Item = Document>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Document>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl From<DocumentCollection> for Vec<Document>
impl From<DocumentCollection> for Vec<Document>
sourcefn from(docs: DocumentCollection) -> Self
fn from(docs: DocumentCollection) -> Self
Converts to this type from the input type.
sourceimpl Index<usize> for DocumentCollection
impl Index<usize> for DocumentCollection
sourceimpl IntoIterator for DocumentCollection
impl IntoIterator for DocumentCollection
sourceimpl PartialEq<DocumentCollection> for DocumentCollection
impl PartialEq<DocumentCollection> for DocumentCollection
sourcefn eq(&self, other: &DocumentCollection) -> bool
fn eq(&self, other: &DocumentCollection) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &DocumentCollection) -> bool
fn ne(&self, other: &DocumentCollection) -> bool
This method tests for !=.
impl StructuralPartialEq for DocumentCollection
Auto Trait Implementations
impl RefUnwindSafe for DocumentCollection
impl Send for DocumentCollection
impl Sync for DocumentCollection
impl Unpin for DocumentCollection
impl UnwindSafe for DocumentCollection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more