1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
use crate::error::C3p0Error; pub trait C3p0Pool: Clone { type CONN; fn connection(&self) -> Result<Self::CONN, C3p0Error>; fn transaction<T, E: From<C3p0Error>, F: FnOnce(&Self::CONN) -> Result<T, E>>( &self, tx: F, ) -> Result<T, E>; } pub trait SqlConnection { fn batch_execute(&self, sql: &str) -> Result<(), C3p0Error>; /* fn execute(&self, sql: &str, params: &[& dyn ToSql]) -> Result<ExecuteResult, C3p0Error>; fn fetch_one_value<T: FromSql>(&self, sql: &str, params: &[& dyn ToSql]) -> Result<T, C3p0Error>; fn fetch_one<T, F: Fn(&Row) -> Result<T, Box<dyn std::error::Error>>>( &self, sql: &str, params: &[& dyn ToSql], mapper: F, ) -> Result<T, C3p0Error>; fn fetch_one_option<T, F: Fn(&Row) -> Result<T, Box<dyn std::error::Error>>>( &self, sql: &str, params: &[& dyn ToSql], mapper: F, ) -> Result<Option<T>, C3p0Error>; fn fetch_all<T, F: Fn(&Row) -> Result<T, Box<dyn std::error::Error>>>( &self, sql: &str, params: &[& dyn ToSql], mapper: F, ) -> Result<Vec<T>, C3p0Error>; fn fetch_all_values<T: FromSql>( &self, sql: &str, params: &[& dyn ToSql], ) -> Result<Vec<T>, C3p0Error>; //count_all_from_table //lock_table */ }