data-stream is a binary serialization library focused on simplicity.
It provides two core traits:
ToStreamFromStream
Implement these traits for your types to write to impl Write and read from impl Read.
Why?
This crate is built for straightforward binary I/O without a large abstraction layer.
Many existing solutions are built around broader data models and generic serialization frameworks. That can be useful, but it can also add complexity when you only want explicit binary read/write behavior.
With data-stream, manual implementations are simple:
you write or read fields in the order you define.
Because everything is stream-based, integration with files, sockets, and in-memory buffers is direct.
Features
Implemented:
- Booleans (
bool) - Numbers (
u8tou128,i8toi128,f32,f64,usize) - Fixed-size arrays (
[T; N]) - Text types (
char,String,strfor writing) - Wrapper types (
Box,Option,Result) - Collections (
Vec,VecDeque,LinkedList,HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap) - Derive macros (
data-stream-derive)
Settings:
- Endianness via
EndianSettings - Collection/string size encoding via
SizeSettings - Ready-to-use defaults:
default_settings::NativeSettingsdefault_settings::PortableSettings
Notes
PortableSettingsis recommended for stable cross-platform binary formats.NativeSettingsis useful for local/native performance-oriented formats.strsupports writing (ToStream), while owned text reading is done viaString(FromStream).