1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! # Generic Frame Encoder
//!
//! Serialise your protocol frames into **on-the-wire bytes** efficiently.
//!
//! **Why this is useful**
//! - Central place to define how a frame becomes a byte sequence (length-prefix, TLV, IPC, …).
//! - Keeps responsibility for buffer management with the caller.
//! - Plays nicely with any sink (files, sockets, custom transports).
//!
//! Implement `FrameEncoder` for your format; call `encode()` to append the wire bytes into a buffer.
use io;
use crateStreamBuffer;
/// Implement this trait for any wire format requiring message serialisation,
/// such as Arrow IPC, protobuf, or custom binary protocols.
///
/// The encoder must only append to the provided buffer and must not retain references
/// or have side-effects to any data passed in.
///
/// ### Safety Contract
/// - The encoder must not mutate the frame being encoded.
/// - The encoder must not retain references to input data after the call.
/// - All writes must be bounded to the provided buffer.