derive_sql/traits/
query.rs

1use super::*;
2
3/// Generic trait to be implemented by SQL drivers (or more likely by proxy to SQL drivers) so that the 
4/// functionalities provided by this crate can be leveraged
5pub trait QueryTrait<R>
6where R: Row,
7{
8
9/*
10  fn query_first<T, P, R, F>(&mut self, query: &str, params: P, f: F) -> Result<Option<T>>
11  where P: Params,
12        R: Row,
13        F: FnOnce(&R) -> Result<T>;
14        */
15
16  fn query_row(&mut self, query: &str) -> Result<Vec<R>>;
17  /*
18  {
19    self.query_row_with_params(query, ())
20  }
21
22  fn query_row_with_params<P>(&mut self, query: &str, params: P) -> Result<Vec<R>>
23  where P: Params;
24  */
25}
26
27/*
28pub trait Row {
29  fn get_string(&self, i: usize) -> Result<Option<String>>;
30  fn get_i64(&self, i: usize)    -> Result<Option<i64>>;
31}
32*/
33
34/*
35struct Value<T> 
36where T: FromValue
37{
38  value: T,
39}
40
41pub trait FromValue {
42  fn as_string(&self) -> Option<String>;
43  fn as_i64(&self)    -> Option<i64>;
44}
45
46#[cfg(attribute = "sqlite")]
47impl FromValue for ::rusqlite::types::FromSql {
48*/
49  
50
51
52/*
53pub struct Value<T> 
54where T: FromValue,
55{
56  t: T,
57}
58
59
60pub trait FromValue<T> {
61  fn from(t: T) -> Result<Self>;
62}
63
64#[cfg(feature = "sqlite")]
65impl FromValue<T: rusqlite::types::ValueRef<'_>> for String { 
66  fn from(t: T) -> Result<Self> { Ok(rusqlite::types::FromSql::column_result(t)?) }
67}
68*/
69