-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodec.rs
More file actions
21 lines (18 loc) · 857 Bytes
/
Copy pathcodec.rs
File metadata and controls
21 lines (18 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! `MessagePackCodec` trait — unified encode/decode contract for the
//! wire-format-aligned types in [`crate::message_pack_format::portable`].
use super::Error;
/// Round-trippable MessagePack codec.
///
/// All [`crate::message_pack_format::portable`] sketch / aggregator types implement this trait;
/// it is the single entry point for encode/decode against the wire format.
///
/// There is no `dyn`-safe usage — callers always know the concrete
/// type — so impls are dispatched statically (zero-cost) via
/// monomorphization.
pub trait MessagePackCodec: Sized {
/// Serialize `self` to MessagePack bytes matching the wire format
/// shared with `sketchlib-go`.
fn to_msgpack(&self) -> Result<Vec<u8>, Error>;
/// Deserialize a MessagePack byte slice into `Self`.
fn from_msgpack(bytes: &[u8]) -> Result<Self, Error>;
}