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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Serialization and deserialization traits and implementations.
//!
//! This module provides the core abstraction layer for encoding Rust types into bytes
//! and decoding bytes back into Rust types. It is the foundation of the library's
//! "any-format" design, allowing seamless format selection at runtime.
//!
//! # Overview
//!
//! The encoders module defines two primary traits:
//!
//! - [`Encoder`] - Converts Rust types into byte sequences
//! - [`Decoder`] - Converts byte sequences back into Rust types
//!
//! These traits are object-safe and thread-safe, making them suitable for dynamic
//! dispatch through trait objects. This enables applications to support multiple
//! serialization formats without recompiling, or even switch formats at runtime based
//! on configuration or message metadata.
//!
//! # Built-in Formats
//!
//! The library includes ready-to-use implementations for:
//!
//! - **JSON** (feature `json`) - Human-readable, widely compatible, available via [`json`] module
//! - **MessagePack** (feature `msgpack`) - Compact binary format, faster than JSON, available via [`msgpack`] module
//!
//! # Custom Formats
//!
//! You are not limited to built-in formats. Implement [`Encoder`] and [`Decoder`] for any
//! serialization format you need:
//! - Other binary formats: CBOR, Protocol Buffers, Avro, Parquet
//! - Custom formats: domain-specific binary protocols, compressed formats
//! - Specialized formats: for specific use cases or performance requirements
//!
//! # Feature Flags
//!
//! - `json` - Enables JSON encoding/decoding support
//! - `msgpack` - Enables MessagePack encoding/decoding support
//!
//! # Examples
//!
//! Using the JSON encoder/decoder:
//!
//! ```rust,no_run
//! use serde::{Serialize, Deserialize};
//! use object_transfer::encoders::{Encoder, Decoder};
//! #[cfg(feature = "json")]
//! use object_transfer::encoders::{JSONEncoder, JSONDecoder};
//!
//! #[derive(Serialize, Deserialize)]
//! struct Event {
//! id: u32,
//! name: String,
//! }
//!
//! # #[cfg(feature = "json")]
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let encoder = JSONEncoder::new();
//! let decoder = JSONDecoder::new();
//!
//! let event = Event { id: 1, name: "test".to_string() };
//! let bytes = encoder.encode(&event)?;
//! let decoded: Event = decoder.decode(bytes)?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;