Skip to main content

tank_core/query/
prepared.rs

1use crate::{AsValue, Result};
2use std::{
3    any::Any,
4    fmt::{Debug, Display},
5};
6
7/// Parameterized, backend-prepared query handle.
8///
9/// Enables pre-parsing and parameter binding.
10///
11/// # Semantics
12/// * `bind`: Append value.
13/// * `bind_index`: Set value at 0-based index.
14pub trait Prepared: Any + Send + Sync + Display + Debug {
15    fn as_any(self: Box<Self>) -> Box<dyn Any>;
16    /// Clear all bindings.
17    fn clear_bindings(&mut self) -> Result<&mut Self>
18    where
19        Self: Sized;
20    /// Bind next value.
21    fn bind(&mut self, value: impl AsValue) -> Result<&mut Self>
22    where
23        Self: Sized;
24    /// Bind value at index.
25    fn bind_index(&mut self, value: impl AsValue, index: u64) -> Result<&mut Self>
26    where
27        Self: Sized;
28    /// True if the query has no meaningful value (the meaning depends on the driver).
29    fn is_empty(&self) -> bool {
30        false
31    }
32}