pub trait FromWireValue<'a>: Sized {
// Required methods
fn from_text(oid: Oid, bytes: &'a [u8]) -> Result<Self>;
fn from_binary(oid: Oid, bytes: &'a [u8]) -> Result<Self>;
// Provided method
fn from_null() -> Result<Self> { ... }
}Expand description
Trait for decoding PostgreSQL values into Rust types.
This trait provides methods for decoding values from different formats:
from_null()- Handle NULL valuesfrom_text()- Decode from text format (simple queries)from_binary()- Decode from binary format (extended queries)
The OID parameter allows implementations to check the PostgreSQL type and reject incompatible types with clear error messages.
Required Methods§
Sourcefn from_text(oid: Oid, bytes: &'a [u8]) -> Result<Self>
fn from_text(oid: Oid, bytes: &'a [u8]) -> Result<Self>
Decode from text format bytes.
Text format is the default for simple queries. Values are UTF-8 encoded string representations.
Sourcefn from_binary(oid: Oid, bytes: &'a [u8]) -> Result<Self>
fn from_binary(oid: Oid, bytes: &'a [u8]) -> Result<Self>
Decode from binary format bytes.
Binary format uses PostgreSQL’s internal representation. Integers are big-endian, floats are IEEE 754, etc.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.