Crate data_buffer
source ·Expand description
This crate defines a buffer data structure optimized to be written to and read from standard
Vec
s. 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 will produce
undefined behavior.
Caveats
DataBuffer
doesn’t support zero-sized types.
Re-exports
pub extern crate reinterpret;
Modules
Utility macros for code generation.
Macros
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
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).