Crates.io | explicit-endian |
lib.rs | explicit-endian |
version | 0.1.6 |
source | src |
created_at | 2023-09-07 00:29:24.31198 |
updated_at | 2024-08-19 14:55:53.629812 |
description | Transparent traits to explicitely declare in-memory endianness for a virable or struct record |
homepage | |
repository | https://gitlab.com/aruiz/rust-explicit-endian |
max_upload_size | |
id | 965777 |
size | 10,967 |
The Rust Explicit Endian Conversion Library, named "explicit-endian," is a lightweight, no_std Rust crate that simplifies data conversion between different endianness formats. It serves as a valuable tool for managing binary data on systems with varying endianness, ensuring consistent and compatible data handling across different platforms.
To integrate the "explicit-endian" crate into your Rust project, add it as a dependency in your Cargo.toml
file:
[dependencies]
explicit-endian = "*"
After adding the dependency, you can import the crate and utilize its functionality within your code:
extern crate explicit_endian as ee;
use ee::{LittleEndian, BigEndian, Swappable};
fn main() {
let value = 42u32;
// Convert to little-endian
let le_value: LittleEndian<u32> = value.into();
// Convert to big-endian
let be_value: BigEndian<u32> = value.into();
// You can now work with le_value and be_value in their respective endianness formats.
}
The library supports the following data types for conversion:
u16
, u32
, u64
, u128
i16
, i32
, i64
, i128
usize
, isize
f32
, f64
For in-depth information about the available functions and types, please consult the API documentation.
You can explore usage examples and additional test cases in the tests
module of the library's source code.
This library is distributed under the terms of the Mozilla Public License, v. 2.0. You can obtain a copy of the MPL 2.0 license here.
Contributions to this library are warmly welcomed. If you encounter any issues or have suggestions for improvements, please do not hesitate to open an issue or submit a pull request on the GitHub repository.
The "explicit-endian" crate was thoughtfully crafted by Alberto Ruiz aruiz@gnome.org. We extend our gratitude to the Rust community for their continuous support and valuable contributions. I would also like to thank OpenAI for generating this README file straight from the source code using ChatGPT.