urex_binary_io/
lib.rs

1//! A crate that implements endianed BinaryReaders for use in urex.
2//!
3//! This crate provides the [`BinaryRead`] and [`BinaryWrite`] traits and three implementations of them each.
4//!
5//! The [`BinaryRead`] and [`BinaryWrite`] traits aren't implemented for [`std::io::Read`] and [`std::io::Write`] respectively, because
6//! they are not endian aware. Instead, they are implemented for the three endian aware structs that either set the endianness or make it variable.
7//!
8//! The implementations are namely:
9//! - [`BinaryReaderVE`], [`BinaryReaderLE`], [`BinaryReaderBE`]
10//! - [`BinaryWriterVE`], [`BinaryWriterLE`], [`BinaryWriterBE`].
11//!
12//! The `VE` stands for variable endian, the `LE` stands for little-endian, and the `BE` stands for big-endian.
13//!
14//! The [`BinaryReaderVE`] and [`BinaryWriterVE`] structs are flexible, allowing you to set and change the endianness at runtime.
15//! The endianness can be set by setting the `endian` field, which is of type [`Endian`].<br>
16//! The [`BinaryReaderLE`] and [`BinaryWriterLE`] structs are restrictive, as they only allow you to read/write little-endian data.<br>
17//! The [`BinaryReaderBE`] and [`BinaryWriterBE`] structs are restrictive, as they only allow you to read/write big-endian data.
18
19mod reader;
20mod writer;
21
22pub use reader::{BinaryRead, BinaryReadAlign, BinaryReaderBE, BinaryReaderLE, BinaryReaderVE};
23pub use writer::{BinaryWrite, BinaryWriteAlign, BinaryWriterBE, BinaryWriterLE, BinaryWriterVE};
24
25/// A simple enum to represent the endianness of the data.<br>
26/// For use with the [`BinaryReaderVE`] and [`BinaryReaderBE`] structs.
27pub enum Endian {
28    Little,
29    Big,
30}