Crate in_situ [] [src]

In Situ Endian-independent Bytes Access

Contents

Usage

This crate is on crates.io and can be used by adding in-situ to the dependencies in your project's Cargo.toml:

[dependencies]
in-situ = "0.1"

# Optionally enable `i128_type` support on nightly Rust.
#[dependencies.in-situ]
#features = ["i128"]

and this to your crate root:

// Optionally enable `i128_type` support on nightly Rust.
// Required if the `i128` feature is enabled in your `Cargo.toml`.
//#![feature(i128_type)]

extern crate in_situ;

Enums

Order

Type describing the underlying byte order.

Traits

InSitu

Provides endian-independent immutable bytes access, thus requires methods to be implemented detecting or hardcoding the word size and endianness. This trait requires the AsRef<[u8]> trait to access slices of generic types. It is not implemented for the Raw trait but instead for its wrapper types since each wrapper might implement the endianness detection differently.

InSituMut

Provides endian-independent mutable bytes access, thus requires InSitu trait to know about endianness. This trait is auto-implemented for all InSitu + AsMut<[u8]> implementors.

Raw

Abstracts immutable as well as mutable generic bytes view types like [u8], mut [u8], Bytes, or BytesMut as immutable views and requires some standard nice-to-have but easily-to-get traits, so the wrapper can just derive them. Requires methods to be implemented to split views into subviews.

RawMut

Abstracts mutable generic bytes view types like mut [u8] or BytesMut as mutable view. This trait is auto-implemented for Raw + AsMut<[u8]> implementors extending the immutable views with mutable ones.

Functions

aligned

Calculates aligned bytes offset via two's complement shortcuts instead of branching and modulo operations.

padding

Calculates padding of aligned bytes offset via two's complement shortcuts instead of branching and modulo operations.