lexa_database/
interface.rs

1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX)         ┃
3// ┃ SPDX-License-Identifier: MPL-2.0                                          ┃
4// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
5// ┃                                                                           ┃
6// ┃  This Source Code Form is subject to the terms of the Mozilla Public      ┃
7// ┃  License, v. 2.0. If a copy of the MPL was not distributed with this      ┃
8// ┃  file, You can obtain one at https://mozilla.org/MPL/2.0/.                ┃
9// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
10
11// --------- //
12// Interface //
13// --------- //
14
15#[async_trait::async_trait]
16pub trait SGBD: Clone {
17	type Pool;
18
19	/// Ouvre une connexion immédiate à la base de données.
20	async fn new(
21		connection_url: impl AsRef<str> + ToString + Send + Sync,
22	) -> Result<Self, crate::Error>
23	where
24		Self: Sized;
25
26	/// Ouvre une pool de connexion à partir d'une URL.
27	async fn create_pool(
28		url: impl AsRef<str> + Send + Sync,
29	) -> Result<Self::Pool, crate::Error>;
30
31	/// Pool de connexion de la base de données.
32	fn pool(&self) -> &Self::Pool;
33}