drizzle_postgres/
traits.rs1mod column;
2mod table;
3pub use column::*;
4use std::any::Any;
5pub use table::*;
6
7use crate::PostgresValue;
8use drizzle_core::{SQLColumn, error::DrizzleError};
9
10pub trait PostgresColumn<'a>: SQLColumn<'a, PostgresValue<'a>> {
11 const SERIAL: bool = false;
12 const BIGSERIAL: bool = false;
13 const GENERATED_IDENTITY: bool = false;
14}
15
16pub trait PostgresEnum: Send + Sync + Any {
18 fn enum_type_name(&self) -> &'static str;
20
21 fn as_enum(&self) -> &dyn PostgresEnum;
22
23 fn variant_name(&self) -> &'static str;
25
26 fn into_boxed(&self) -> Box<dyn PostgresEnum>;
28
29 fn try_from_str(value: &str) -> Result<Self, DrizzleError>
31 where
32 Self: Sized;
33}
34
35impl std::fmt::Debug for &dyn PostgresEnum {
36 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 f.debug_struct("PostgresSQLEnum")
38 .field("type", &self.enum_type_name())
39 .field("variant", &self.variant_name())
40 .finish()
41 }
42}
43
44impl PartialEq for &dyn PostgresEnum {
45 fn eq(&self, other: &Self) -> bool {
46 self.enum_type_name() == other.enum_type_name()
47 && self.variant_name() == other.variant_name()
48 }
49}
50
51impl std::fmt::Debug for Box<dyn PostgresEnum> {
52 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53 f.debug_struct("PostgresSQLEnum")
54 .field("type", &self.enum_type_name())
55 .field("variant", &self.variant_name())
56 .finish()
57 }
58}
59
60impl Clone for Box<dyn PostgresEnum> {
61 fn clone(&self) -> Self {
62 self.into_boxed()
63 }
64}
65
66impl PartialEq for Box<dyn PostgresEnum> {
67 fn eq(&self, other: &Self) -> bool {
68 self.enum_type_name() == other.enum_type_name()
69 && self.variant_name() == other.variant_name()
70 }
71}