pub struct StatementMachine { /* private fields */ }Expand description
The pure statement lifecycle driver. Construct with StatementMachine::new,
then feed each response with StatementMachine::on_submit /
StatementMachine::on_poll / StatementMachine::on_partition.
Implementations§
Source§impl StatementMachine
impl StatementMachine
Sourcepub fn drain_rows(&mut self) -> Vec<Vec<Option<String>>>
pub fn drain_rows(&mut self) -> Vec<Vec<Option<String>>>
Streaming (reality-check bead E5): take the rows assembled so far, in
partition order, so a caller can write them out before the next
partitions arrive. Drained rows still count toward
StatementMachine::rows_assembled and the final numRows check; the
completed statement then holds only the rows not yet drained.
Sourcepub fn result_set(&self) -> Option<&ResultSet>
pub fn result_set(&self) -> Option<&ResultSet>
While assembling: the terminal result set (metadata and column types).
Sourcepub const fn polls_done(&self) -> u32
pub const fn polls_done(&self) -> u32
Number of poll GETs consumed so far.
Sourcepub fn assembling_window(&self) -> Option<(u32, u32)>
pub fn assembling_window(&self) -> Option<(u32, u32)>
While assembling: (next partition to fetch, total partitions).
Sourcepub fn rows_assembled(&self) -> usize
pub fn rows_assembled(&self) -> usize
Rows assembled so far (the inline partition plus every fetched partition).
Sourcepub fn complete_early(&mut self) -> Result<CompletedStatement, LifecycleError>
pub fn complete_early(&mut self) -> Result<CompletedStatement, LifecycleError>
Finish with the partitions fetched so far (row-cap stop). The result is
partial: fetched_partitions < total_partitions, rows is a prefix.
§Errors
LifecycleErrorCode::UnexpectedStatus outside the assembling phase.
Sourcepub fn on_submit(
&mut self,
class: ResponseClass,
body: &[u8],
) -> Result<Progress, LifecycleError>
pub fn on_submit( &mut self, class: ResponseClass, body: &[u8], ) -> Result<Progress, LifecycleError>
Feed the response to POST /api/v2/statements.
§Errors
LifecycleError if the body fails to decode or the status is one a
submit can never legitimately return.
Sourcepub fn on_poll(
&mut self,
class: ResponseClass,
body: &[u8],
) -> Result<Progress, LifecycleError>
pub fn on_poll( &mut self, class: ResponseClass, body: &[u8], ) -> Result<Progress, LifecycleError>
Feed the response to a poll GET /api/v2/statements/{handle}.
§Errors
LifecycleError on decode failure, an unexpected status, or an
exhausted poll quota.
Sourcepub fn on_partition(
&mut self,
class: ResponseClass,
partition: u32,
body: &[u8],
) -> Result<Progress, LifecycleError>
pub fn on_partition( &mut self, class: ResponseClass, partition: u32, body: &[u8], ) -> Result<Progress, LifecycleError>
Feed the response to a partition GET ...?partition=N. body is the
decoded (post-gzip) partition payload: a bare JSON array of rows.
§Errors
LifecycleError on decode failure, a non-200 status, an out-of-order
partition, a per-partition row count that disagrees with
partitionInfo[*].rowCount, or a final row count that disagrees with
numRows.