Skip to main content

FromWireValue

Trait FromWireValue 

Source
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 values
  • from_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§

Source

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.

Source

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§

Source

fn from_null() -> Result<Self>

Decode from NULL value.

Default implementation returns an error. Override for types that can represent NULL (like Option<T>).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromWireValue<'_> for String

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for Vec<u8>

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for bool

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for f32

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for f64

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for i16

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for i32

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl FromWireValue<'_> for i64

Source§

fn from_text(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &[u8]) -> Result<Self>

Source§

impl<'a, T: FromWireValue<'a>> FromWireValue<'a> for Option<T>

Source§

fn from_null() -> Result<Self>

Source§

fn from_text(oid: Oid, bytes: &'a [u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &'a [u8]) -> Result<Self>

Source§

impl<'a> FromWireValue<'a> for &'a [u8]

Source§

fn from_text(oid: Oid, bytes: &'a [u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &'a [u8]) -> Result<Self>

Source§

impl<'a> FromWireValue<'a> for &'a str

Source§

fn from_text(oid: Oid, bytes: &'a [u8]) -> Result<Self>

Source§

fn from_binary(oid: Oid, bytes: &'a [u8]) -> Result<Self>

Implementors§