Struct planus::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

Builder for serializing flatbuffers.

Examples

use planus::Builder;
use planus_example::monster_generated::my_game::sample::Weapon;
let mut builder = Builder::new();
let weapon = Weapon::create(&mut builder, "Axe", 24);
builder.finish(weapon, None);

Implementations§

Creates a new Builder.

Gets the length of the internal buffer in bytes.

Returns true if the internal buffer is empty.

Creates a new builder with a specific internal capacity already allocated.

Resets the builders internal state and clears the internal buffer.

Finish writing the internal buffer and return a byte slice of it.

This will make sure all alignment requirements are fullfilled and that the file identifier has been written if specified.

Examples
use planus::Builder;
use planus_example::monster_generated::my_game::sample::Weapon;
let mut builder = Builder::new();
let weapon = Weapon::create(&mut builder, "Axe", 24);
builder.finish(weapon, None);

It can also be used to directly serialize an owned flatbuffers struct

use planus::Builder;
use planus_example::monster_generated::my_game::sample::Weapon;
let mut builder = Builder::new();
let weapon = Weapon { name: Some("Sword".to_string()), damage: 12 };
let data = builder.finish(&weapon, None);

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.