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.3"

and this to your crate root:

extern crate in_situ;

Enums

Order

Type describing the underlying byte order.

Take

Type of from methods' argument specifying to take the bytes of either the header only or the whole packet.

Constants

F32

Size of f32.

F64

Size of f64.

I8

Size of i8.

I16

Size of i16.

I24

Size of i24.

I32

Size of i32.

I64

Size of i64.

I128

Size of i128.

U8

Size of u8.

U16

Size of u16.

U24

Size of u24.

U32

Size of u32.

U64

Size of u64.

U128

Size of u128.

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.