pub struct Vector<T> { /* fields omitted */ }
A container holding a contiguous sequence of flatdata structs of the same
type T
in memory, and providing read and write access to it.
Vector data is fully stored and populated in memory before it is
serialized. This container is often used for data which needs to be changed
or updated after insertion in the container. When data can be incrementally
serialized without later updates, ExternalVector
is usually a
better choice since it may decrease the memory footprint of serialization
significantly.
An archive builder provides a setter for each vector resource. Use
as_view
and the corresponding setter to write a Vector
to storage.
use flatdata::Vector;
define_struct!(A, AMut, "no_schema", 4,
(x, set_x, u32, 0, 16),
(y, set_y, u32, 16, 16)
);
let mut v: Vector<A> = Vector::new();
{
let mut a = v.grow();
a.set_x(1);
a.set_y(2);
}
{
let mut b = v.grow();
b.set_x(3);
b.set_y(4);
}
assert_eq!(v.len(), 2);
Creates an empty Vector<T>
.
Creates a Vector<T>
with len
many elements.
T
's fields are all filled with zeroes.
Size of the vector in bytes.
Number of elements in the vector.
Returns true
if the vector has a length 0.
Reserves capacity for at least additional
more elements to be
inserted in the given vector. The collection may reserve more space
to avoid frequent reallocations. After calling reserve, capacity
will be greater than or equal to self.len() + additional
. Does nothing
if capacity is already sufficient.
Returns an ArrayView
to this vector.
Returns the contents of this vector as slice of bytes.
Appends an element to the end of this vector and returns a mutable
handle to it.
Return an accessor handle to the element at position index
in the
vector.
Return a mutable handle to the element at position index
in the
vector.
Performs copy-assignment from source
. Read more
Creates an empty Vector<T>
.
Returns the content of this vector as slice of bytes. Equivalent to
as_bytes
.
Formats the value using the given formatter. Read more