degen_sql/db/postgres/models/
model.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::mem::discriminant;

use serde_json::Error as SerdeJsonError;
use tokio_postgres::Error as PostgresError;

pub trait Model {}

#[derive(Debug, thiserror::Error )]
pub enum PostgresModelError {
    #[error("Timeout")]
    Timeout,

    #[error(transparent)]
    Postgres(#[from] PostgresError),

    #[error(transparent)]
    SerdeJson(#[from] SerdeJsonError),

    #[error("Error parsing row for database: {0:?}")]
    RowParseError(Option<String>),

}

impl PartialEq for PostgresModelError {
    fn eq(&self, other: &Self) -> bool {
        discriminant(self) == discriminant(other)
    }
}

impl Eq for PostgresModelError {}