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