lexa_database/interface.rs
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX) ┃
// ┃ SPDX-License-Identifier: MPL-2.0 ┃
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
// ┃ ┃
// ┃ This Source Code Form is subject to the terms of the Mozilla Public ┃
// ┃ License, v. 2.0. If a copy of the MPL was not distributed with this ┃
// ┃ file, You can obtain one at https://mozilla.org/MPL/2.0/. ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// --------- //
// Interface //
// --------- //
#[async_trait::async_trait]
pub trait SGBD: Clone {
type Pool;
/// Ouvre une connexion immédiate à la base de données.
async fn new(
connection_url: impl AsRef<str> + ToString + Send + Sync,
) -> Result<Self, crate::Error>
where
Self: Sized;
/// Ouvre une pool de connexion à partir d'une URL.
async fn create_pool(
url: impl AsRef<str> + Send + Sync,
) -> Result<Self::Pool, crate::Error>;
/// Pool de connexion de la base de données.
fn pool(&self) -> &Self::Pool;
}