use sqlx::PgPool; pub type DBConn = PgPool; const UNIQUE_CONSTRAINT_VIOLATION_CODE: &str = "2067"; fn is_unique_constraint_violation(err: &sqlx::Error) -> bool { if let sqlx::Error::Database(db_err) = err { if let Some(code) = db_err.code() { if code == UNIQUE_CONSTRAINT_VIOLATION_CODE { return true; } } } false } fn is_row_not_found_error(err: &sqlx::Error) -> bool { if let sqlx::Error::RowNotFound = err { return true; } false }