Struct FlatBufferBuilderPool

Source
pub struct FlatBufferBuilderPool { /* private fields */ }
Expand description

FlatBufferBuilder pool.

§Examples

use flatbuffers_pool::FlatBufferBuilderPool;

let mut b = FlatBufferBuilderPool::get();
let name = b.create_string("something fun");
b.finish(name, None);

Implementations§

Source§

impl FlatBufferBuilderPool

Source

pub fn get() -> GlobalBuilder

Get the FlatBufferBuilder from the global pool.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

let mut b = FlatBufferBuilderPool::get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn init_global_pool_size(size: usize)

Change the initial global pool size.

It should be called before calling the first get function otherwise the change won’t applicable.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

FlatBufferBuilderPool::init_global_pool_size(0);
let mut b = FlatBufferBuilderPool::get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn max_global_pool_size(size: usize)

Change the maximum global pool size.

It should be called before calling the first get function otherwise the change won’t applicable.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

FlatBufferBuilderPool::max_global_pool_size(4);
let mut b = FlatBufferBuilderPool::get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn global_buffer_capacity(capacity: usize)

Change the initial FlatBufferBuilder buffer size.

The value only applicable for the newly allocated FlatBufferBuilder instances.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

FlatBufferBuilderPool::global_buffer_capacity(64);
let mut b = FlatBufferBuilderPool::get();
let name = b.create_string("something fun");
b.finish(name, None);
Source§

impl FlatBufferBuilderPool

Source

pub fn new() -> Self

Create a local FlatBufferBuilder pool instance.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

// Get the builder from the local pool.
let mut pool = FlatBufferBuilderPool::new().build();
let mut b = pool.get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn init_pool_size(self, size: usize) -> Self

Change the initial local pool size.

It should be called before calling the first get function otherwise the change won’t applicable.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

// Get the builder from the local pool.
let pool = FlatBufferBuilderPool::new()
    .init_pool_size(0)
    .build();
let mut b = pool.get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn max_pool_size(self, size: usize) -> Self

Change the maximum local pool size.

It should be called before calling the first get function otherwise the change won’t applicable.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

// Get the builder from the local pool.
let pool = FlatBufferBuilderPool::new()
    .max_pool_size(4)
    .build();
let mut b = pool.get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn buffer_capacity(self, capacity: usize) -> Self

Change the initial FlatBufferBuilder buffer size.

The value only applicable for the newly allocated FlatBufferBuilder instances.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

// Get the builder from the local pool.
let pool = FlatBufferBuilderPool::new()
    .buffer_capacity(64)
    .build();
let mut b = pool.get();
let name = b.create_string("something fun");
b.finish(name, None);
Source

pub fn build<'a>(&self) -> FlatBufferBuilderLocalPool<'a>

Build a local FlatBufferBuilder pool.

§Examples
use flatbuffers_pool::FlatBufferBuilderPool;

// Get the builder from the local pool.
let pool = FlatBufferBuilderPool::new()
    .build();
let mut b = pool.get();
let name = b.create_string("something fun");
b.finish(name, None);

Trait Implementations§

Source§

impl Default for FlatBufferBuilderPool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.