scry_protocol/database_event/mod.rs
1//! Database event types and serialization.
2//!
3//! This module provides types for database replication events (COPY, CDC, proxy)
4//! with FlexBuffers serialization for efficient wire format.
5//!
6//! # Design
7//!
8//! The key design decision is storing PostgreSQL binary format bytes directly
9//! in `ColumnValue.data` to enable zero-copy for the high-throughput COPY path.
10//!
11//! # Example
12//!
13//! ```rust
14//! use scry_protocol::database_event::{
15//! DatabaseEventBuilder, BatchBuilder, Row, ColumnValue, TypeTag,
16//! serialize_batch, read_batch,
17//! };
18//!
19//! // Build an event
20//! let event = DatabaseEventBuilder::insert("public", "users")
21//! .position(12345)
22//! .new_row(Row::new(vec![
23//! ColumnValue::from_pg_binary(TypeTag::Int32, 23, vec![0, 0, 0, 1]),
24//! ]))
25//! .build();
26//!
27//! // Build a batch
28//! let mut builder = BatchBuilder::new().source_id("my-source");
29//! builder.add_event(event);
30//! let batch = builder.finish().unwrap();
31//!
32//! // Serialize
33//! let bytes = serialize_batch(&batch).unwrap();
34//!
35//! // Deserialize
36//! let recovered = read_batch(&bytes).unwrap();
37//! ```
38
39mod types;
40mod builder;
41mod reader;
42
43pub use types::*;
44pub use builder::{DatabaseEventBuilder, BatchBuilder};
45pub use reader::{serialize_batch, serialize_event, read_batch, read_event};