rocket_sync_db_pools/
error.rs

1use rocket::figment;
2
3/// A wrapper around `r2d2::Error`s or a custom database error type.
4///
5/// This type is only relevant to implementors of the [`Poolable`] trait. See
6/// the [`Poolable`] documentation for more information on how to use this type.
7///
8/// [`Poolable`]: crate::Poolable
9#[derive(Debug)]
10pub enum Error<T> {
11    /// A custom error of type `T`.
12    Custom(T),
13    /// An error occurred while initializing an `r2d2` pool.
14    Pool(r2d2::Error),
15    /// An error occurred while extracting a `figment` configuration.
16    Config(figment::Error),
17}
18
19impl<T> From<figment::Error> for Error<T> {
20    fn from(error: figment::Error) -> Self {
21        Error::Config(error)
22    }
23}
24
25impl<T> From<r2d2::Error> for Error<T> {
26    fn from(error: r2d2::Error) -> Self {
27        Error::Pool(error)
28    }
29}