pub struct StatementHandle { /* private fields */ }Expand description
Handle to a submitted statement execution.
| Operation | Method |
|---|---|
| Read the last observed status without a request | snapshot |
| Fetch the current status | refresh |
| Wait for results | wait |
| Request cancellation | cancel |
Terminal statuses (Finished, Failed, Cancelled) are cached locally, so
subsequent calls to refresh, wait, or
cancel return without another network request. Dropping a refresh or wait
future stops local waiting without cancelling execution on the server.
Implementations§
Source§impl StatementHandle
impl StatementHandle
Sourcepub fn statement_id(&self) -> Uuid
pub fn statement_id(&self) -> Uuid
Returns the statement ID.
Sourcepub fn snapshot(&self) -> Option<&StatementStatus>
pub fn snapshot(&self) -> Option<&StatementStatus>
Returns the most recently observed StatementStatus, if any, without
making a network request.
Sourcepub async fn refresh(&mut self) -> Result<&StatementStatus, Error>
pub async fn refresh(&mut self) -> Result<&StatementStatus, Error>
Fetches and caches the latest StatementStatus, or returns the cached
status if already terminal.
Sourcepub async fn wait(&mut self) -> Result<ResultSet, Error>
pub async fn wait(&mut self) -> Result<ResultSet, Error>
Polls until the statement reaches a terminal state and returns its ResultSet.
Returns ErrorKind::Cancelled if the statement was cancelled, or
normalizes a server execution failure into Error with
Error::statement_details. Retry transient polling errors by calling
wait again on this handle.
Sourcepub async fn cancel(&mut self) -> Result<StatementStatus, Error>
pub async fn cancel(&mut self) -> Result<StatementStatus, Error>
Requests cancellation and caches the returned StatementStatus.
If the response status is still Pending or Running, call wait
to await termination. If execution finished or failed before cancellation
took effect, that terminal status is returned and cached.