Crate zero_postgres

Crate zero_postgres 

Source
Expand description

A high-performance PostgreSQL client library.

§Features

  • Zero-copy parsing: Message payloads are parsed directly from the read buffer
  • Sans-I/O state machines: Protocol logic is separated from I/O
  • Sync and async APIs: Choose between synchronous and tokio-based async
  • Full protocol support: Simple query, extended query, COPY, pipelining

§Example

use zero_postgres::sync::Conn;
use zero_postgres::Opts;

fn main() -> zero_postgres::Result<()> {
    let opts = Opts {
        host: "localhost".into(),
        user: "postgres".into(),
        database: Some("mydb".into()),
        password: Some("secret".into()),
        ..Default::default()
    };

    let mut conn = Conn::new(opts)?;

    let rows: Vec<(i32,)> = conn.query_collect("SELECT 1 AS num")?;
    println!("Rows: {:?}", rows);

    conn.close()?;
    Ok(())
}

Re-exports§

pub use handler::AsyncMessageHandler;
pub use state::action::AsyncMessage;
pub use state::extended::PreparedStatement;

Modules§

conversion
Type encoding and decoding for PostgreSQL wire protocol.
handler
Typed result handlers.
protocol
PostgreSQL wire protocol implementation.
state
Sans-I/O state machines for PostgreSQL protocol.
sync
Synchronous PostgreSQL client.
tokio
Asynchronous PostgreSQL client using Tokio.

Structs§

BufferPool
Buffer pool for reusing BufferSet instances across connections.
BufferSet
Buffer set for state machine operations.
Opts
Connection options for PostgreSQL.
ServerError
PostgreSQL server error/notice message.
Ticket
A ticket for a queued pipeline operation.

Enums§

Error
Error type for zero-postgres.
SslMode
SSL connection mode.

Traits§

IntoStatement
Sealed trait for types that can be used as statement references in exec_* methods.

Type Aliases§

Result
Result type for zero-postgres operations.