Struct flatbuffers::FlatBufferBuilder[][src]

pub struct FlatBufferBuilder<'fbb> { /* fields omitted */ }

FlatBufferBuilder builds a FlatBuffer through manipulating its internal state. It has an owned Vec<u8> that grows as needed (up to the hardcoded limit of 2GiB, which is set by the FlatBuffers format).

Methods

impl<'fbb> FlatBufferBuilder<'fbb>
[src]

Create a FlatBufferBuilder that is ready for writing.

Create a FlatBufferBuilder that is ready for writing, with a ready-to-use capacity of the provided size.

The maximum valid value is FLATBUFFERS_MAX_BUFFER_SIZE.

Reset the FlatBufferBuilder internal state. Use this method after a call to a finish function in order to re-use a FlatBufferBuilder.

This function is the only way to reset the finished state and start again.

If you are using a FlatBufferBuilder repeatedly, make sure to use this function, because it re-uses the FlatBufferBuilder's existing heap-allocated Vec<u8> internal buffer. This offers significant speed improvements as compared to creating a new FlatBufferBuilder for every new object.

Destroy the FlatBufferBuilder, returning its internal byte vector and the index into it that represents the start of valid data.

Push a Push'able value onto the front of the in-progress data.

This function uses traits to provide a unified API for writing scalars, tables, vectors, and WIPOffsets.

Push a Push'able value onto the front of the in-progress data, and store a reference to it in the in-progress vtable. If the value matches the default, then this is a no-op.

Push a Push'able value onto the front of the in-progress data, and store a reference to it in the in-progress vtable.

Retrieve the number of vtables that have been serialized into the FlatBuffer. This is primarily used to check vtable deduplication.

Start a Table write.

Asserts that the builder is not in a nested state.

Users probably want to use push_slot to add values after calling this.

End a Table write.

Asserts that the builder is in a nested state.

Start a Vector write.

Asserts that the builder is not in a nested state.

Most users will prefer to call create_vector. Speed optimizing users who choose to create vectors manually using this function will want to use push to add values.

End a Vector write.

Note that the num_elems parameter is the number of written items, not the byte count.

Asserts that the builder is in a nested state.

Create a utf8 string.

The wire format represents this as a zero-terminated byte vector.

Create a zero-terminated byte vector.

Create a vector by memcpy'ing. This is much faster than calling create_vector, but the underlying type must be represented as little-endian on the host machine. This property is encoded in the type system through the SafeSliceAccess trait. The following types are always safe, on any platform: bool, u8, i8, and any FlatBuffers-generated struct.

Create a vector of strings.

Speed-sensitive users may wish to reduce memory usage by creating the vector manually: use create_vector, push, and end_vector.

Create a vector of Push-able objects.

Speed-sensitive users may wish to reduce memory usage by creating the vector manually: use create_vector, push, and end_vector.

Get the byte slice for the data that has been written, regardless of whether it has been finished.

Get the byte slice for the data that has been written after a call to one of the finish functions.

Assert that a field is present in the just-finished Table.

This is somewhat low-level and is mostly used by the generated code.

Finalize the FlatBuffer by: aligning it, pushing an optional file identifier on to it, pushing a size prefix on to it, and marking the internal state of the FlatBufferBuilder as finished. Afterwards, users can call finished_data to get the resulting data.

Finalize the FlatBuffer by: aligning it, pushing an optional file identifier on to it, and marking the internal state of the FlatBufferBuilder as finished. Afterwards, users can call finished_data to get the resulting data.

Finalize the FlatBuffer by: aligning it and marking the internal state of the FlatBufferBuilder as finished. Afterwards, users can call finished_data to get the resulting data.

Auto Trait Implementations

impl<'fbb> Send for FlatBufferBuilder<'fbb>

impl<'fbb> Sync for FlatBufferBuilder<'fbb>