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;
27#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
28mod conversion_error;
29mod decoder;
30mod error;
31#[cfg(any(feature = "maxwell", feature = "wal2json"))]
32mod json_decoders;
33#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
34mod json_helpers;
35mod scalar_helpers;
36mod sealed;
37#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
38mod shared_builders;
39mod source;
40mod temporal;
41mod type_map;
42#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
43mod uuid_helpers;
44mod wire_type;
45
46#[cfg(feature = "maxwell")]
47mod impls_maxwell;
48mod impls_pg_binary;
49#[cfg(feature = "pg-walstream")]
50mod impls_pg_walstream;
51#[cfg(feature = "wal2json")]
52mod impls_wal2json;
53
54pub use adapter::WireAdapter;
55#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
56pub use conversion_error::ConversionError;
57pub use decoder::Decoder;
58pub use decoder::{
59    BoolDecoder, DateDecoder, DecimalTextDecoder, Int64OverflowToTextDecoder, IntDecoder,
60    IntervalDecoder, JsonCanonicalDecoder, JsonVerbatimDecoder, MySqlBinaryDecoder, NullDecoder,
61    PgByteaBinaryDecoder, PgByteaTextModeDecoder, RealDecoder, TextDecoder, TimeDecoder,
62    TimestampDecoder, TimestampTzDecoder, UuidBlob16Decoder, UuidText36Decoder,
63};
64pub use error::DecodeError;
65#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
66pub(crate) use sealed::Sealed;
67#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
68pub(crate) use shared_builders::{
69    WireColumnItem, build_changeset_delete, build_insert, build_patch_delete,
70    build_patchset_update, resolve_table,
71};
72pub use source::{Digestable, PgBinary, PgBinaryColumn, WireColumnTypes, WireSchema, WireSource};
73pub use type_map::{TypeMap, TypeMapDefaults};
74pub use wire_type::WireType;