postgleam/codec

Types

A resolved codec that can encode and decode values for a specific OID

pub type Codec {
  Codec(
    type_name: String,
    oid: Int,
    format: Format,
    encode: fn(value.Value) -> Result(BitArray, String),
    decode: fn(BitArray) -> Result(value.Value, String),
  )
}

Constructors

  • Codec(
      type_name: String,
      oid: Int,
      format: Format,
      encode: fn(value.Value) -> Result(BitArray, String),
      decode: fn(BitArray) -> Result(value.Value, String),
    )

    Arguments

    type_name

    PostgreSQL type name (e.g. “bool”, “int4”)

    oid

    OID of this type

    format

    Wire format this codec uses

    encode

    Encode a Value to binary payload (without length header)

    decode

    Decode binary payload (without length header) to a Value

A codec matcher - used to build the registry by matching OIDs to codecs

pub type CodecMatcher {
  CodecMatcher(
    type_name: String,
    oids: List(Int),
    send: option.Option(String),
    format: Format,
    build: fn(Int) -> Codec,
  )
}

Constructors

  • CodecMatcher(
      type_name: String,
      oids: List(Int),
      send: option.Option(String),
      format: Format,
      build: fn(Int) -> Codec,
    )

    Arguments

    type_name

    PostgreSQL type name

    oids

    Known OIDs this matcher handles (empty = match by send function)

    send

    PostgreSQL send function name (for matching by catalog)

    format

    Wire format

    build

    Create a codec for a given OID

Wire format: binary or text

pub type Format {
  Binary
  Text
}

Constructors

  • Binary
  • Text
Search Document