Expand description
FromProof + Fetch for [DocumentSum] — the single-value
aggregate sum view of the unified getDocuments endpoint.
Sum-side analog of super::document_count. Callers build a
DocumentQuery with .with_select(Select::Sum) and
.with_select_field("amount"); whatever the request shape,
this impl returns a single i64 (the aggregate sum).
Empty entries (verifier emitted None for a queried-but-absent
branch) contribute 0 to the sum via filter_map(|e| e.sum).
Overflow handling: the fold uses i64::checked_add and returns
a RequestError on overflow rather than panicking (debug) or
wrapping (release). A grovedb sum-tree’s per-node aggregate
itself fits in i64 by construction, but a multi-entry fold
across carrier-aggregate / distinct branches can in principle
exceed that — the verifier surfaces it explicitly so callers
can switch to DocumentSplitSums (which preserves per-branch
i64s and lets the caller pick its own arithmetic).