pub struct QueryResult {
pub columns: Vec<String>,
pub rows: Vec<Row>,
/* private fields */
}Expand description
Query result containing column names and rows.
Invariant: rows.len() == row_group_keys.len(). Always. Mutating
either field directly will violate this; use the helper methods
(add_row, add_aggregate_row, truncate, sort_by, etc.) that
keep both vectors in lockstep. The invariant is enforced at runtime
with assert_eq! inside sort_by.
Fields§
§columns: Vec<String>Column names.
rows: Vec<Row>Result rows.
Implementations§
Source§impl QueryResult
impl QueryResult
Sourcepub fn add_row(&mut self, row: Row)
pub fn add_row(&mut self, row: Row)
Add a row to the result with no GROUP BY context (non-aggregate path).
The sidecar (row_group_keys) records None for this row, so the
text renderer applies no per-currency quantization (issue #988).
Aggregate paths must use Self::add_aggregate_row instead.
Sourcepub fn add_aggregate_row(&mut self, row: Row, group_key: Vec<Value>)
pub fn add_aggregate_row(&mut self, row: Row, group_key: Vec<Value>)
Add a row produced by aggregation, recording the GROUP BY key values alongside it. The renderer consults the key to quantize numeric aggregates against the per-currency display precision (issue #988).
Multi-column GROUP BY note: when several columns are grouped (e.g.
GROUP BY account, currency), the entire key is preserved here.
The renderer’s currency-hint extraction (currency_hint_for_row
in rustledger/src/cmd/query/output.rs) takes the first
currency-shaped string in iteration order — so put the currency
column first if both are currency-shaped, which is rare in
practice but possible.
Sourcepub fn group_key(&self, row_idx: usize) -> Option<&[Value]>
pub fn group_key(&self, row_idx: usize) -> Option<&[Value]>
Get the GROUP BY key for a given row, if it was produced by
aggregation. Returns None for non-aggregate rows or when the
row index is out of range. This is the public read-side of the
row_group_keys sidecar — prefer it over reaching into the
field directly.
Returns &[Value] rather than &Vec<Value> so callers aren’t
tied to the specific container type.
Sourcepub fn has_aggregate_rows(&self) -> bool
pub fn has_aggregate_rows(&self) -> bool
Whether any row in the result was produced by aggregation. Lets
downstream renderers short-circuit per-row hint lookups when
the cache would be all None anyway (issue #988 follow-up).
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncate to the first len rows, keeping row_group_keys in
lockstep so the parallel-vector invariant survives LIMIT.
Trait Implementations§
Source§impl Clone for QueryResult
impl Clone for QueryResult
Source§fn clone(&self) -> QueryResult
fn clone(&self) -> QueryResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for QueryResult
impl RefUnwindSafe for QueryResult
impl Send for QueryResult
impl Sync for QueryResult
impl Unpin for QueryResult
impl UnsafeUnpin for QueryResult
impl UnwindSafe for QueryResult
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.