PgEncoder

Struct PgEncoder 

Source
pub struct PgEncoder;
Expand description

Takes a Qail and produces wire protocol bytes. This is the “Visitor” in the visitor pattern.

Implementations§

Source§

impl PgEncoder

Source

pub fn encode_query_string(sql: &str) -> BytesMut

Encode a raw SQL string as a Simple Query message. Wire format:

  • ‘Q’ (1 byte) - message type
  • length (4 bytes, big-endian, includes self)
  • query string (null-terminated)
Source

pub fn encode_terminate() -> BytesMut

Encode a Terminate message to close the connection.

Source

pub fn encode_sync() -> BytesMut

Encode a Sync message (end of pipeline in extended query protocol).

Source

pub fn encode_parse(name: &str, sql: &str, param_types: &[u32]) -> BytesMut

Encode a Parse message (prepare a statement). Wire format:

  • ‘P’ (1 byte) - message type
  • length (4 bytes)
  • statement name (null-terminated, “” for unnamed)
  • query string (null-terminated)
  • parameter count (2 bytes)
  • parameter OIDs (4 bytes each, 0 = infer type)
Source

pub fn encode_bind( portal: &str, statement: &str, params: &[Option<Vec<u8>>], ) -> Result<BytesMut, EncodeError>

Encode a Bind message (bind parameters to a prepared statement). Wire format:

  • ‘B’ (1 byte) - message type
  • length (4 bytes)
  • portal name (null-terminated)
  • statement name (null-terminated)
  • format code count (2 bytes) - we use 0 (all text)
  • parameter count (2 bytes)
  • for each parameter: length (4 bytes, -1 for NULL), data
  • result format count (2 bytes) - we use 0 (all text)
Source

pub fn encode_execute(portal: &str, max_rows: i32) -> BytesMut

Encode an Execute message (execute a bound portal). Wire format:

  • ‘E’ (1 byte) - message type
  • length (4 bytes)
  • portal name (null-terminated)
  • max rows (4 bytes, 0 = unlimited)
Source

pub fn encode_describe(is_portal: bool, name: &str) -> BytesMut

Encode a Describe message (get statement/portal metadata). Wire format:

  • ‘D’ (1 byte) - message type
  • length (4 bytes)
  • ‘S’ for statement or ‘P’ for portal
  • name (null-terminated)
Source

pub fn encode_extended_query( sql: &str, params: &[Option<Vec<u8>>], ) -> Result<BytesMut, EncodeError>

Encode a complete extended query pipeline (OPTIMIZED). This combines Parse + Bind + Execute + Sync in a single buffer. Zero intermediate allocations - writes directly to pre-sized BytesMut.

Source§

impl PgEncoder

Source

pub fn encode_bind_ultra<'a>( buf: &mut BytesMut, statement: &str, params: &[Param<'a>], ) -> Result<(), EncodeError>

Encode Bind message - ULTRA OPTIMIZED.

  • Direct integer writes (no temp arrays)
  • Borrowed params (zero-copy)
  • Single allocation check
Source

pub fn encode_execute_ultra(buf: &mut BytesMut)

Encode Execute message - ULTRA OPTIMIZED.

Source

pub fn encode_sync_ultra(buf: &mut BytesMut)

Encode Sync message - ULTRA OPTIMIZED.

Source

pub fn encode_bind_to( buf: &mut BytesMut, statement: &str, params: &[Option<Vec<u8>>], ) -> Result<(), EncodeError>

Encode Bind message directly into existing buffer (ZERO ALLOCATION). This is the hot path optimization - no intermediate Vec allocation.

Source

pub fn encode_execute_to(buf: &mut BytesMut)

Encode Execute message directly into existing buffer (ZERO ALLOCATION).

Source

pub fn encode_sync_to(buf: &mut BytesMut)

Encode Sync message directly into existing buffer (ZERO ALLOCATION).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ColumnValue<Value> for T