Skip to main content

sqlite_diff_rs/
wire.rs

1//! Schema-aware forward conversion from CDC wire formats into
2//! [`Value`](crate::encoding::Value).
3//!
4//! Every supported wire source (`pg_walstream`, `wal2json`, `maxwell`)
5//! carries per-column type metadata alongside the raw value bytes. This
6//! module funnels the three sources through one shared decoding contract
7//! so users can register a single type-to-decoder mapping and consume
8//! multiple wire formats interchangeably.
9//!
10//! # Shape
11//!
12//! - [`WireSource`] (sealed): per-source marker with an associated
13//!   payload struct and type key. Implemented by `PgWalstream`,
14//!   `Wal2Json`, `Maxwell`.
15//! - [`Decoder`]: one implementation per (source, semantic) pair.
16//!   Zero-sized unit types for stateless decoders (`BoolDecoder`,
17//!   `IntDecoder`, ...), state-carrying structs for user config.
18//! - [`WireAdapter`]: single-method dispatcher fed a per-column
19//!   payload, returns a [`Value`](crate::encoding::Value).
20//! - [`TypeMap`]: generic hashmap-backed [`WireAdapter`] implementation
21//!   keyed by `Src::TypeKey`. The primary user-facing type.
22//! - [`TypeMapDefaults`]: per-source `defaults()` builder for a
23//!   [`TypeMap`] pre-populated with the crate's self-evident mappings.
24mod adapter;
25#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
26mod bytes_helpers;
27mod decoder;
28mod error;
29#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
30mod json_helpers;
31mod sealed;
32mod source;
33mod type_map;
34#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
35mod uuid_helpers;
36
37#[cfg(feature = "maxwell")]
38mod impls_maxwell;
39#[cfg(feature = "pg-walstream")]
40mod impls_pg_walstream;
41#[cfg(feature = "wal2json")]
42mod impls_wal2json;
43
44pub use adapter::WireAdapter;
45pub use decoder::Decoder;
46pub use decoder::{
47    BoolDecoder, DateVerbatimDecoder, DecimalTextDecoder, Int64OverflowToTextDecoder, IntDecoder,
48    IntervalVerbatimDecoder, JsonCanonicalDecoder, JsonVerbatimDecoder, MySqlBinaryDecoder,
49    NullDecoder, PgByteaBinaryDecoder, PgByteaTextModeDecoder, RealDecoder, TextDecoder,
50    TimeVerbatimDecoder, TimestampTzVerbatimDecoder, TimestampVerbatimDecoder, UuidBlob16Decoder,
51    UuidText36Decoder,
52};
53pub use error::DecodeError;
54#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
55pub(crate) use sealed::Sealed;
56pub use source::{Digestable, WireColumnTypes, WireSchema, WireSource};
57pub use type_map::{TypeMap, TypeMapDefaults};