cdrs_async/query/
query_executor.rs1use std::pin::Pin;
2
3use async_trait::async_trait;
4use cassandra_proto::{
5 error,
6 frame::Frame,
7 query::{QueryParams, QueryParamsBuilder, QueryValues},
8};
9
10#[async_trait]
12pub trait QueryExecutor: Send {
13 async fn query_with_params_tw<Q: ToString + Send>(
14 mut self: Pin<&mut Self>,
15 query: Q,
16 query_params: QueryParams,
17 with_tracing: bool,
18 with_warnings: bool,
19 ) -> error::Result<Frame>;
20
21 async fn query<Q: ToString + Send>(mut self: Pin<&mut Self>, query: Q) -> error::Result<Frame> {
24 self.query_tw(query, false, false).await
25 }
26
27 async fn query_tw<Q: ToString + Send>(
30 mut self: Pin<&mut Self>,
31 query: Q,
32 with_tracing: bool,
33 with_warnings: bool,
34 ) -> error::Result<Frame> {
35 let query_params = QueryParamsBuilder::new().finalize();
36 self
37 .query_with_params_tw(query, query_params, with_tracing, with_warnings)
38 .await
39 }
40
41 async fn query_with_values<Q: ToString + Send, V: Into<QueryValues> + Send>(
43 mut self: Pin<&mut Self>,
44 query: Q,
45 values: V,
46 ) -> error::Result<Frame> {
47 self.query_with_values_tw(query, values, false, false).await
48 }
49
50 async fn query_with_values_tw<Q: ToString + Send, V: Into<QueryValues> + Send>(
53 mut self: Pin<&mut Self>,
54 query: Q,
55 values: V,
56 with_tracing: bool,
57 with_warnings: bool,
58 ) -> error::Result<Frame> {
59 let query_params_builder = QueryParamsBuilder::new();
60 let query_params = query_params_builder.values(values.into()).finalize();
61 self
62 .query_with_params_tw(query, query_params, with_tracing, with_warnings)
63 .await
64 }
65
66 async fn query_with_params<Q: ToString + Send>(
68 mut self: Pin<&mut Self>,
69 query: Q,
70 query_params: QueryParams,
71 ) -> error::Result<Frame> {
72 self
73 .query_with_params_tw(query, query_params, false, false)
74 .await
75 }
76}