[][src]Crate data_buffer

This crate defines a buffer data structure optimized to be written to and read from standard Vecs. DataBuffer is particularly useful when dealing with data whose type is determined at run time. Note that data is stored in the underlying byte buffers in native endian form, thus requesting typed data from a buffer on a platform with different endianness is unsafe.

Caveats

DataBuffer doesn't support zero-sized types.

Re-exports

pub use reinterpret;

Modules

macros

Utility macros for code generation.

Macros

call_numeric_buffer_fn

Applies $fn to an DataBuffer mapping valid numeric data types by corresponding generic parameters. For example, passing an DataBuffer containing data of type u8 will cause this macro to call $fn with type parameter u8 like $fn::<u8>(buffer).

Structs

DataBuffer

Buffer of plain old data. The data is stored as an array of bytes (Vec<u8>). DataBuffer keeps track of the type stored within via an explicit TypeId member. This allows one to hide the type from the compiler and check it only when necessary. It is particularly useful when the type of data is determined at runtime (e.g. when parsing numeric data).