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 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.
Trait Implementations§
Source§impl Clone for StatementMachine
impl Clone for StatementMachine
Source§fn clone(&self) -> StatementMachine
fn clone(&self) -> StatementMachine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more