Skip to main content

weir_core/
lib.rs

1//! Core wire-protocol types shared by the weir daemon, client, and sink SDK.
2//!
3//! `weir-core` is the dependency-light foundation of the weir workspace: it
4//! defines the v1 binary frame format and nothing else (no I/O, no async, no
5//! daemon logic). Everything that crosses the socket is built from these types.
6//!
7//! # What's here
8//!
9//! - [`Envelope`] / [`Header`] — a complete wire frame and its 16-byte header,
10//!   with `encode`/`decode` that own the CRC and validation order.
11//! - [`MessageType`] / [`Durability`] / [`NackReason`] — the fixed-repr enums
12//!   carried in the header and Nack payloads, each with a `TryFrom<u8>` whose
13//!   error is [`UnknownMessageType`] / [`UnknownDurability`] / [`UnknownNackReason`]
14//!   (re-exported here alongside the enums).
15//! - [`RecordCoordinate`] — where an accepted record landed in the WAB, carried
16//!   back by an [`AckTracked`](MessageType::AckTracked) frame.
17//! - [`Payload`] — opaque, ref-counted payload bytes (O(1) clone).
18//! - [`DecodeError`] / [`WeirError`] — the decode failure taxonomy.
19//! - [`WIRE_VERSION`] / [`MAX_PAYLOAD_HARD_CAP`] / [`HEADER_LEN`] /
20//!   [`MIN_FRAME_LEN`] — the protocol constants.
21//!
22//! The wire format itself is specified in `docs/wire_protocol.md`; this crate
23//! is its executable reference (see `tests/reference_frames.rs`).
24#![deny(missing_docs)]
25
26pub mod batch;
27pub mod coordinate;
28pub mod durability;
29pub mod envelope;
30pub mod error;
31pub mod nack;
32pub mod payload;
33pub mod version;
34
35pub use batch::{
36    ACK_BATCH_HEADER_LEN, ACK_BATCH_VERSION, BATCH_HEADER_LEN, BATCH_VERSION, BatchError,
37    MAX_ACK_BATCH_PAYLOAD_LEN, MAX_BATCH_RECORDS_HARD_CAP, bitmap_bit, decode_ack_batch,
38    decode_batch_body, encode_ack_batch, encode_batch_body,
39};
40pub use coordinate::{
41    COORDINATE_FIXED_LEN, COORDINATE_VERSION, CoordinateError, MAX_SEGMENT_NAME_LEN,
42    MAX_TRACKED_ACK_PAYLOAD_LEN, RecordCoordinate,
43};
44pub use durability::{Durability, UnknownDurability};
45pub use envelope::{Envelope, HEADER_LEN, Header, MIN_FRAME_LEN, MessageType, UnknownMessageType};
46pub use error::{DecodeError, WeirError};
47pub use nack::{NackReason, UnknownNackReason};
48pub use payload::Payload;
49pub use version::{MAX_PAYLOAD_HARD_CAP, WIRE_VERSION};