Skip to content

Commit

Permalink
use byteorder crate for more efficient array reading
Browse files Browse the repository at this point in the history
  • Loading branch information
K0lb3 committed Mar 30, 2023
1 parent 03dd9a5 commit a92ddb1
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 281 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "urex-binary-io"
version = "0.1.1"
version = "0.1.2"
rust-version = "1.61"
edition = "2021"
authors = ["Rudolf Kolbe <rkolbe96@gmail.com>"]
Expand All @@ -15,3 +15,4 @@ exclude = [".git*"]
[dependencies]
half = "2.2.1"
paste = "1.0.12"
byteorder = "1.4.3"
24 changes: 14 additions & 10 deletions src/lib.rs
@@ -1,26 +1,30 @@
//! A crate that implements endianed BinaryReaders for use in urex.
//!
//! This crate provides the [`BinaryReader`] and [`BinaryWriter`] traits and three implementations of them each,
//!
//! The [`BinaryReader`] and [`BinaryWriter`] traits aren't implemented for `Read` and `Write` respectively, because
//! they are not endian aware. Instead, they are implemented for the three endian aware structs that either set the endianness or make it variable.
//! This crate provides the [`BinaryRead`] and [`BinaryWrite`] traits and three implementations of them each.
//!
//! The [`BinaryRead`] and [`BinaryWrite`] traits aren't implemented for [`std::io::Read`] and [`std::io::Write`] respectively, because
//! they are not endian aware. Instead, they are implemented for the three endian aware structs that either set the endianness or make it variable.
//!
//! The implementations are namely:
//! - [`BinaryReaderVE`], [`BinaryReaderLE`], [`BinaryReaderBE`]
//! - [`BinaryWriterVE`], [`BinaryWriterLE`], [`BinaryWriterBE`].
//!
//!
//! The `VE` stands for variable endian, the `LE` stands for little-endian, and the `BE` stands for big-endian.
//!
//! The [`BinaryReaderVE`] and [`BinaryWriterVE`] structs are flexible, allowing you to set and change the endianness at runtime.
//! The endianness can be set by setting the `endian` field, which is of type [`Endian`].
//! The [`BinaryReaderLE`] and [`BinaryWriterLE`] structs are restrictive, as they only allow you to read/write little-endian data.
//! The endianness can be set by setting the `endian` field, which is of type [`Endian`].<br>
//! The [`BinaryReaderLE`] and [`BinaryWriterLE`] structs are restrictive, as they only allow you to read/write little-endian data.<br>
//! The [`BinaryReaderBE`] and [`BinaryWriterBE`] structs are restrictive, as they only allow you to read/write big-endian data.

mod reader;
mod writer;

pub use reader::{BinaryReader, BinaryReaderBE, BinaryReaderLE, BinaryReaderVE};
pub use writer::{BinaryWriter, BinaryWriterBE, BinaryWriterLE, BinaryWriterVE};
pub use reader::{BinaryRead, BinaryReadAlign, BinaryReaderBE, BinaryReaderLE, BinaryReaderVE};
pub use writer::{BinaryWrite, BinaryWriteAlign, BinaryWriterBE, BinaryWriterLE, BinaryWriterVE};

/// A simple enum to represent the endianness of the data.<br>
/// For use with the [`BinaryReaderVE`] and [`BinaryReaderBE`] structs.
pub enum Endian {
Little,
Big,
}
}

0 comments on commit a92ddb1

Please sign in to comment.