| 15 | /// ``` |
| 16 | #[rocket::async_trait] |
| 17 | pub trait Pool: Sized + Send + Sync + 'static { |
| 18 | /// The connection type managed by this pool. |
| 19 | type Connection; |
| 20 | |
| 21 | /// The error type returned by [`Self::init()`]. |
| 22 | type Error: std::error::Error; |
| 23 | |
| 24 | /// Constructs a pool from a [Value](rocket::figment::value::Value). |
| 25 | /// |
| 26 | /// It is up to each implementor of `Pool` to define its accepted |
| 27 | /// configuration value(s) via the `Config` associated type. Most |
| 28 | /// integrations provided in `sea_orm_rocket` use [`Config`], which |
| 29 | /// accepts a (required) `url` and an (optional) `pool_size`. |
| 30 | /// |
| 31 | /// ## Errors |
| 32 | /// |
| 33 | /// This method returns an error if the configuration is not compatible, or |
| 34 | /// if creating a pool failed due to an unavailable database server, |
| 35 | /// insufficient resources, or another database-specific error. |
| 36 | async fn init(figment: &Figment) -> Result<Self, Self::Error>; |
| 37 | |
| 38 | /// Borrows a reference to the pool |
| 39 | fn borrow(&self) -> &Self::Connection; |
| 40 | } |
| 41 | |
| 42 | #[derive(Debug)] |
| 43 | /// A mock object which impl `Pool`, for testing only |