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 type_map;
41#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
42mod uuid_helpers;
43mod wire_type;
44
45#[cfg(feature = "maxwell")]
46mod impls_maxwell;
47mod impls_pg_binary;
48#[cfg(feature = "pg-walstream")]
49mod impls_pg_walstream;
50#[cfg(feature = "wal2json")]
51mod impls_wal2json;
52
53pub use adapter::WireAdapter;
54#[cfg(any(feature = "wal2json", feature = "maxwell", feature = "pg-walstream"))]
55pub use conversion_error::ConversionError;
56pub use decoder::Decoder;
57pub use decoder::{
58    BoolDecoder, DateVerbatimDecoder, DecimalTextDecoder, Int64OverflowToTextDecoder, IntDecoder,
59    IntervalVerbatimDecoder, JsonCanonicalDecoder, JsonVerbatimDecoder, MySqlBinaryDecoder,
60    NullDecoder, PgByteaBinaryDecoder, PgByteaTextModeDecoder, RealDecoder, TextDecoder,
61    TimeVerbatimDecoder, TimestampTzVerbatimDecoder, TimestampVerbatimDecoder, UuidBlob16Decoder,
62    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;