A simple endian-handling library for Rust

Overview

endi

Build Status API Documentation crates.io

Yet another endian handling library for Rust. The approach is very similar to that of byteordered crate with its Endianness enum, except that endi is much simpler and doesn't depend on byteorder (or anything at all).

Usage

The main type is Endian enum which can be either Big or Little. It provides various methods to read and write integers of different sizes and endianness.

use endi::{Endian, ReadBytes, WriteBytes};

let mut buf = [0u8; 4];
for endian in [Endian::Little, Endian::Big] {
    endian.write_u32(&mut buf, 0xAB_BA_FE_EF);
    assert_eq!(endian.read_u32(&buf), 0xAB_BA_FE_EF);

    // Using the `ReadBytes` and `WriteBytes` traits:
    let mut cursor = std::io::Cursor::new(&mut buf[..]);
    cursor.write_u32(endian, 0xAB_BA_FE_EF).unwrap();
    cursor.set_position(0);
    assert_eq!(cursor.read_u32(endian).unwrap(), 0xAB_BA_FE_EF);
}

nostd

You can disable std by disabling the default std feature. This will disable the ReadBytes and WriteBytes traits.

License

MIT

You might also like...
TypeRust - simple Rust playground where you can build or run your Rust code and share it with others

Rust playground Welcome to TypeRust! This is a simple Rust playground where you can build or run your Rust code and share it with others. There are a

Simple and performant hot-reloading for Rust

reloady Simple, performant hot-reloading for Rust. Requires Rust nightly and only works on Linux for now. installing CLI To install the CLI helper car

Crabzilla provides a simple interface for running JavaScript modules alongside Rust code.

Crabzilla Crabzilla provides a simple interface for running JavaScript modules alongside Rust code. Example use crabzilla::*; use std::io::stdin; #[i

Simple daemon built with Rust to track metrics.

Marvin - Metrics Tracker What I cannot create, I do not understand. — Richard Feynman Simple daemon built with Rust to track metrics. The goal is run

A simple programming language for something between C and Rust.

inuc inuc is a systems programming language that is something between C and Rust. Features : [] Strong , static typing (type inference not a priority

Rust language from simple to deep, and then to strengthen learning in multiple module

Rust Library This project is used to learn rust language from simple to deep, and then to strengthen learning in multiple module. It is used to help n

Fast and simple datetime, date, time and duration parsing for rust.

speedate Fast and simple datetime, date, time and duration parsing for rust. speedate is a lax† RFC 3339 date and time parser, in other words, it pars

Simple RESTful API in rust created with actix-web. (Routing, models, JWT auth).

rust-simple-api Simple RESTful API created with rust, actix-web, Diesel, JWT. Running application Manual Firstly generate a secret.key which will be u

Simple Rust 🦀 api with Rocket 🚀

Car API Written in Rust & Rocket.rs 🦀 🚀 Running project Running by cargo You just need to run the following command: cargo run Running on docker Fi

Releases(1.1.0)
Owner
Zeeshan Ali Khan
Free Software dev, Ecomodernist, into flying & Rust, and love cats.
Zeeshan Ali Khan
🚃 lib for CLI utilities, printing, and error handling

axocli Common code for setting up a CLI App and handling errors/printing. Example See examples/axoapp.rs for a walkthrough/example. Some various inter

axo 5 Apr 4, 2023
derive(Code) simplifies error handling by providing an easy-to-use enumeration of error codes

enum-code Introduction enum-code is a derive macro for enum types. This library generates code that associates error codes with error types. It can be

Bay 5 Jun 14, 2023
A simple thread schedule and priority library for rust

thread-priority A simple library to control thread schedule policies and thread priority. If your operating system isn't yet supported, please, create

Victor Polevoy 62 Dec 5, 2022
A simple /proc//{mem,maps} library for Rust

Summary A very simple library that wraps around /proc/pid/mem and /proc/pid/maps to read memory out of a running process on Linux. Usage Basic usage l

null 6 Jul 27, 2022
Simple and customizable procedural noise generation library written in Rust.

libnoise A simple, performant, and customizable procedural noise generation library inspired by libnoise for C++ featuring: Easy coherent noise genera

SpoogieOogie 29 Aug 13, 2023
A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages.

uy A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages. Usage uy not only stores the unit of a v

Lachlan Sneff 19 Aug 8, 2023
A simple library to get all pairs from any Dex and sync reserves.

pair_sync A simple library to get all pairs from any supported Dex and sync reserves. Crates.io Documentation in progress Filename: examples/sync-pair

null 116 Dec 30, 2022
A simple local storage media library manager.

OFFFLIX A simple application to auto manage series on your local storage. Features Resume watching Play next episode Auto increment season Play random

null 33 Mar 7, 2023
Rust 核心库和标准库的源码级中文翻译,可作为 IDE 工具的智能提示 (Rust core library and standard library translation. can be used as IntelliSense for IDE tools)

Rust 标准库中文版 这是翻译 Rust 库 的地方, 相关源代码来自于 https://github.com/rust-lang/rust。 如果您不会说英语,那么拥有使用中文的文档至关重要,即使您会说英语,使用母语也仍然能让您感到愉快。Rust 标准库是高质量的,不管是新手还是老手,都可以从中

wtklbm 493 Jan 4, 2023
Simple autoclicker written in Rust, to learn the Rust language.

RClicker is an autoclicker written in Rust, written to learn more about the Rust programming language. RClicker was was written by me to learn more ab

null 7 Nov 15, 2022