bumpy_vector
A vector-like object where elements can be larger than one item. We use this primarily to represent objects in a binary that are made up of one or more bytes.
Goal
h2gb is a tool for analyzing binary files. Importantly, a binary file is a series of objects, each of which take up some number of bytes. We need a datatype to represent this unusual requirement, hence coming up with BumpyVector!
Usage
Instantiate with a maximum size, then use somewhat like a vector:
use ;
// Instantiate with a maximum size of 100 and a type of String
let mut v: = new;
// Create a 10-byte entry at the start
let entry: = BumpyEntry ;
// Insert it into the BumpyVector
assert!;
// Create another entry, this time from a tuple, that overlaps the first
let entry: = .into;
assert!;
// Create an entry that's off the end of the object
let entry: = .into;
assert!;
// There is still one entry in this vector
assert_eq!;
Serialize / deserialize
When installed with the 'serialize' feature:
= { = "~0.0.0", = ["serialize"] }
Serialization support using serde is enabled. The
BumpyVector
can be serialized with any of the serializers that Serde
supports, such as ron:
use BumpyVector;
// Assumes "serialize" feature is enabled: `bumpy_vector = { features = ["serialize"] }`
License: MIT