5 unstable releases
Uses new Rust 2024
| new 0.3.1 | Mar 6, 2026 |
|---|---|
| 0.3.0 | Mar 18, 2025 |
| 0.2.1 | Aug 26, 2024 |
| 0.2.0 | Oct 10, 2022 |
| 0.1.0 | Sep 30, 2021 |
#13 in #btree-map
30 downloads per month
Used in 13 crates
(8 directly)
19KB
373 lines
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).
Dependencies
~76KB