hank_types/
hank.database.rs

1// @generated
2// This file is @generated by prost-build.
3/// Database Query Results.
4#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct Results {
6    /// An array of JSON strings.
7    #[prost(string, repeated, tag="1")]
8    pub rows: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
9}
10/// A prepared statement to execute on the database.
11#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
12#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct PreparedStatement {
15    /// The SQL query to execute, using ? for placeholders.
16    ///
17    /// Example:
18    ///   SELECT * FROM table WHERE id = ?
19    #[prost(string, tag="1")]
20    pub sql: ::prost::alloc::string::String,
21    /// An array of values to substitute each ? placeholder in the SQL query with.
22    #[prost(string, repeated, tag="2")]
23    #[cfg_attr(feature = "builder", builder(setter(custom)))]
24    pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
25}
26// @@protoc_insertion_point(module)
27// Customizations from hank.database.customizations.rs
28#[cfg(feature = "builder")]
29impl PreparedStatement {
30    pub fn new(sql: impl Into<String>) -> PreparedStatementBuilder {
31        PreparedStatementBuilder {
32            sql: Some(sql.into()),
33            ..PreparedStatementBuilder::create_empty()
34        }
35    }
36}
37#[cfg(feature = "builder")]
38impl PreparedStatementBuilder {
39    pub fn values(&mut self, value: impl IntoIterator<Item = impl Into<String>>) -> &mut Self {
40        self.values = Some(value.into_iter().map(Into::into).collect());
41        self
42    }
43    pub fn build(&self) -> PreparedStatement {
44        self.fallible_build()
45            .expect("All required fields were initialized")
46    }
47}