parsql_deadpool_postgres/lib.rs
1pub use parsql_macros as macros;
2
3use tokio_postgres::types::ToSql;
4
5/// Trait for generating SQL queries.
6/// This trait is implemented by the derive macro `Queryable`, `Insertable`, `Updateable`, and `Deletable`.
7pub trait SqlQuery {
8 /// Returns the SQL query string.
9 fn query() -> String;
10}
11
12/// Trait for providing SQL parameters.
13/// This trait is implemented by the derive macro `SqlParams`.
14pub trait SqlParams {
15 /// Returns a vector of references to SQL parameters.
16 fn params(&self) -> Vec<&(dyn ToSql + Sync)>;
17}
18
19/// Trait for providing UPDATE parameters.
20/// This trait is implemented by the derive macro `UpdateParams`.
21pub trait UpdateParams {
22 /// Returns a vector of references to SQL parameters for UPDATE operations.
23 fn params(&self) -> Vec<&(dyn ToSql + Sync)>;
24}
25
26/// Trait for converting database rows to Rust structs.
27/// This trait is implemented by the derive macro `FromRow`.
28pub trait FromRow {
29 /// Converts a database row to a Rust struct.
30 ///
31 /// # Arguments
32 /// * `row` - A reference to a database row
33 ///
34 /// # Returns
35 /// * `Result<Self, Error>` - The converted struct or an error
36 fn from_row(row: &tokio_postgres::Row) -> Result<Self, tokio_postgres::Error>
37 where
38 Self: Sized;
39}
40
41// Transaction işlemleri için modül
42pub mod transactional_ops;
43
44// Transaction işlemleri için takma ad
45pub use transactional_ops as transactional;
46
47// CRUD işlemleri için modül
48mod crud_ops;
49
50// Pool extension işlemleri için modül
51pub mod pool_extensions;
52pub mod transaction_extensions;
53
54// CRUD işlemlerini dışa aktar
55pub use crud_ops::{
56 insert,
57 update,
58 delete,
59 get,
60 get_all,
61 select,
62 select_all
63};
64
65// Pool extension'ları dışa aktar
66pub use pool_extensions::CrudOps;
67pub use transaction_extensions::TransactionOps;
68
69// Deadpool-postgres türlerini dışa aktar
70pub use deadpool_postgres::{Pool, Client as PoolClient, PoolError, Transaction};
71
72// Public olarak Row ve Error türlerini dışa aktar
73pub use tokio_postgres::{Error, Row};