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
impl FlatBufferBuilderPool
Sourcepub fn get() -> GlobalBuilder
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);Sourcepub fn init_global_pool_size(size: usize)
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);Sourcepub fn max_global_pool_size(size: usize)
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);Sourcepub fn global_buffer_capacity(capacity: usize)
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
impl FlatBufferBuilderPool
Sourcepub fn new() -> Self
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);Sourcepub fn init_pool_size(self, size: usize) -> Self
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);Sourcepub fn max_pool_size(self, size: usize) -> Self
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);Sourcepub fn buffer_capacity(self, capacity: usize) -> Self
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);Sourcepub fn build<'a>(&self) -> FlatBufferBuilderLocalPool<'a>
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);