procwire_client/codec/mod.rs
1//! Codec module - serialization/deserialization for payloads.
2//!
3//! This module provides codecs for encoding/decoding frame payloads:
4//!
5//! - [`RawCodec`] - Pass-through for raw bytes (zero-copy)
6//! - [`MsgPackCodec`] - MessagePack using `rmp-serde` (to_vec_named for Node.js compatibility)
7//!
8//! # Design
9//!
10//! Codecs are implemented as marker structs with static methods rather than trait objects.
11//! This allows for compile-time codec selection and enables zero-copy optimizations.
12//!
13//! # Example
14//!
15//! ```
16//! use procwire_client::codec::{MsgPackCodec, RawCodec};
17//! use bytes::Bytes;
18//!
19//! // MsgPack codec for structured data
20//! let encoded = MsgPackCodec::encode(&"hello").unwrap();
21//! let decoded: String = MsgPackCodec::decode(&encoded).unwrap();
22//! assert_eq!(decoded, "hello");
23//!
24//! // Raw codec for binary data
25//! let raw = RawCodec::serialize(b"binary data");
26//! assert_eq!(RawCodec::deserialize(&raw), b"binary data");
27//! ```
28
29mod msgpack;
30mod raw;
31
32pub use msgpack::MsgPackCodec;
33pub use raw::RawCodec;