cdrs_async/query/
prepare_executor.rs

1use std::pin::Pin;
2
3use async_trait::async_trait;
4use cassandra_proto::{error, types::CBytesShort};
5
6/// Id of a prepared query. This Id can be used for
7/// query execution and/or query batching.
8pub type PreparedQuery = CBytesShort;
9
10/// Traits that provides methods for preparing queries
11/// on a DB server.
12#[async_trait]
13pub trait PrepareExecutor {
14  /// It prepares a query for execution, along with query itself
15  /// the method takes `with_tracing` and `with_warnings` flags
16  /// to get tracing information and warnings.
17  async fn prepare_tw<Q: ToString + Send>(
18    mut self: Pin<&mut Self>,
19    query: Q,
20    with_tracing: bool,
21    with_warnings: bool,
22  ) -> error::Result<PreparedQuery>;
23
24  /// It prepares query without additional tracing information and warnings.
25  async fn prepare<Q: ToString + Send>(
26    mut self: Pin<&mut Self>,
27    query: Q,
28  ) -> error::Result<PreparedQuery> {
29    self.prepare_tw(query, false, false).await
30  }
31}