pub trait DrizzlePostgresColumn: Sized {
type SQLType: DataType;
const SQL_TYPE: &'static str;
const NEEDS_CREATE_TYPE: bool = false;
// Required method
fn encode(&self) -> PostgresValue<'_>;
// Provided method
fn encode_owned(self) -> OwnedPostgresValue { ... }
}Expand description
Stub trait when no postgres driver is enabled — allows enum derives to compile
without a driver feature, but the table macro’s TryFrom impls won’t be generated.
The blanket From<Self> for PostgresValue owns the encoded value because
insert/update models may store SQL fragments after the source value is
dropped. Call encode() directly when you need an immediate borrowed value.
Override encode_owned() when consuming self can avoid cloning owned data.
Required Associated Constants§
Provided Associated Constants§
Sourceconst NEEDS_CREATE_TYPE: bool = false
const NEEDS_CREATE_TYPE: bool = false
Whether this requires a CREATE TYPE (native PG enum).
Required Associated Types§
Required Methods§
Sourcefn encode(&self) -> PostgresValue<'_>
fn encode(&self) -> PostgresValue<'_>
Convert self to a PostgresValue for insertion/updates.
Provided Methods§
Sourcefn encode_owned(self) -> OwnedPostgresValue
fn encode_owned(self) -> OwnedPostgresValue
Convert self to an owned PostgreSQL value for stored bind parameters.
The default implementation owns the borrowed result of encode.
Override this for wrappers that can move an internal string or byte buffer
directly into the SQL parameter.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".