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. Each payload carries a semantic [`WireType`].
14//!   Implemented by `PgWalstream`, `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 [`WireType`]. 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;
36mod wire_type;
37
38#[cfg(feature = "maxwell")]
39mod impls_maxwell;
40#[cfg(feature = "pg-walstream")]
41mod impls_pg_walstream;
42#[cfg(feature = "wal2json")]
43mod impls_wal2json;
44
45pub use adapter::WireAdapter;
46pub use decoder::Decoder;
47pub use decoder::{
48    BoolDecoder, DateVerbatimDecoder, DecimalTextDecoder, Int64OverflowToTextDecoder, IntDecoder,
49    IntervalVerbatimDecoder, JsonCanonicalDecoder, JsonVerbatimDecoder, MySqlBinaryDecoder,
50    NullDecoder, PgByteaBinaryDecoder, PgByteaTextModeDecoder, RealDecoder, TextDecoder,
51    TimeVerbatimDecoder, TimestampTzVerbatimDecoder, TimestampVerbatimDecoder, UuidBlob16Decoder,
52    UuidText36Decoder,
53};
54pub use error::DecodeError;
55#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
56pub(crate) use sealed::Sealed;
57pub use source::{Digestable, WireColumnTypes, WireSchema, WireSource};
58pub use type_map::{TypeMap, TypeMapDefaults};
59pub use wire_type::WireType;