kacrab_protocol/lib.rs
1//! Kafka wire protocol — types, framing, record batches, compression, version negotiation.
2//!
3//! # Layout
4//!
5//! Each module owns its data, its operations, and its error (`mod foo` →
6//! `foo.rs` + `foo/error.rs`). The crate root re-exports the user-facing surface
7//! and the symbols `generated/` references via `use crate::*`.
8//!
9//! | Module | Responsibility |
10//! |---------------|---------------------------------------------------------------|
11//! | [`primitives`]| Fixed-width int/float/bool + (un)signed varint(long) helpers. |
12//! | [`string`] | [`KafkaString`] + length-prefixed string read/write helpers. |
13//! | [`bytes_io`] | Length-prefixed raw byte read/write helpers. |
14//! | [`uuid`] | [`KafkaUuid`] + base64 URL-safe parsing (Java-compat). |
15//! | [`tagged`] | [`RawTaggedField`] + flexible-version tagged-field section. |
16//! | [`crc`] | CRC32C compute + validation. |
17//! | [`frame`] | TCP length-prefix framing + request encoding helpers. |
18//! | [`record`] | Record batch v2: [`RecordBatch`](record::RecordBatch), [`Record`](record::Record), [`RecordHeader`](record::RecordHeader). |
19//! | [`compression`]| Codec dispatch (gzip/snappy/lz4/zstd, feature-gated). |
20//! | [`version`] | API version resolution + header version selection. |
21//! | [`generated`] | Codegen output (committed). One module per Kafka message. |
22//!
23//! # Errors
24//!
25//! Each module exposes its own error type co-located in `foo/error.rs`.
26//! The top-level [`ProtocolError`] is a thin facade that `#[from]`-converts
27//! every module error so callers crossing layer boundaries can propagate
28//! errors with a single `?`. See [`crate::error`] for the full mapping.
29pub mod bytes_io;
30pub mod compression;
31pub mod crc;
32pub mod error;
33pub mod frame;
34pub mod generated;
35pub mod primitives;
36pub mod record;
37pub mod string;
38pub mod tagged;
39pub mod uuid;
40pub mod version;
41
42// ---------------------------------------------------------------------------
43// Internal re-exports (`#[doc(hidden)]`) — symbols re-exported at the crate root
44// for `generated/*.rs` (each generated file uses `use crate::*;`). Not part of
45// the public API. Prefer the module path in hand-written code:
46// `crate::primitives::read_i32`, not `crate::read_i32`.
47// ---------------------------------------------------------------------------
48#[doc(hidden)]
49pub use crate::bytes_io::{
50 bytes_len, compact_bytes_len, compact_nullable_bytes_len, nullable_bytes_len, read_bytes,
51 read_compact_bytes, read_compact_nullable_bytes, read_nullable_bytes, write_bytes,
52 write_compact_bytes, write_compact_nullable_bytes, write_nullable_bytes,
53};
54#[doc(hidden)]
55pub use crate::primitives::{
56 array_length_len, array_read_capacity, compact_array_length_len, read_array_length, read_bool,
57 read_compact_array_length, read_f64, read_i8, read_i16, read_i32, read_i64, read_u16, read_u32,
58 signed_varint_len, signed_varlong_len, unsigned_varint_len, unsigned_varlong_len,
59 write_array_length, write_bool, write_compact_array_length, write_f64, write_i8, write_i16,
60 write_i32, write_i64, write_u16, write_u32,
61};
62#[doc(hidden)]
63pub use crate::string::{
64 compact_nullable_string_len, compact_string_len, nullable_string_len,
65 read_compact_nullable_string, read_compact_string, read_nullable_string, read_string,
66 string_len, write_compact_nullable_string, write_compact_string, write_nullable_string,
67 write_string,
68};
69#[doc(hidden)]
70pub use crate::tagged::{read_tagged_fields, tagged_fields_len, write_tagged_fields};
71#[doc(hidden)]
72pub use crate::uuid::{read_uuid, write_uuid};
73// ---------------------------------------------------------------------------
74// Facade re-exports — the user-visible API surface.
75// ---------------------------------------------------------------------------
76pub use crate::{
77 error::{ProtocolError, Result},
78 string::KafkaString,
79 tagged::RawTaggedField,
80 uuid::KafkaUuid,
81 version::{UnsupportedFieldVersion, UnsupportedVersion},
82};