data-stream 0.3.1

A simple serialization library based on streams
Documentation

data-stream is a binary serialization library focused on simplicity.

It provides two core traits:

  • ToStream
  • FromStream

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 (u8 to u128, i8 to i128, f32, f64, usize)
  • Fixed-size arrays ([T; N])
  • Text types (char, String, str for 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::NativeSettings
    • default_settings::PortableSettings

Notes

  • PortableSettings is recommended for stable cross-platform binary formats.
  • NativeSettings is useful for local/native performance-oriented formats.
  • str supports writing (ToStream), while owned text reading is done via String (FromStream).