Struct rarena_allocator::ArenaOptions
source · pub struct ArenaOptions { /* private fields */ }Expand description
Options for creating an ARENA
Implementations§
source§impl ArenaOptions
impl ArenaOptions
sourcepub const fn with_maximum_alignment(self, alignment: usize) -> Self
pub const fn with_maximum_alignment(self, alignment: usize) -> Self
Set the maximum alignment of the ARENA.
If you are trying to allocate a T which requires a larger alignment than this value,
then will lead to read_unaligned, which is undefined behavior on some platforms.
The alignment must be a power of 2.
The default maximum alignment is 8.
§Example
use rarena_allocator::ArenaOptions;
let opts = ArenaOptions::new().with_maximum_alignment(16);sourcepub const fn with_capacity(self, capacity: u32) -> Self
pub const fn with_capacity(self, capacity: u32) -> Self
Set the capacity of the ARENA. This configuration will be ignored if the ARENA is backed by a memory map,
see Arena::map_mut, Arena::map and Arena::map_anon for more details.
The capacity must be greater than the minimum capacity of the ARENA.
The default capacity is 1KB.
§Example
use rarena_allocator::ArenaOptions;
let opts = ArenaOptions::new().with_capacity(2048);sourcepub const fn with_minimum_segment_size(self, minimum_segment_size: u32) -> Self
pub const fn with_minimum_segment_size(self, minimum_segment_size: u32) -> Self
Set the minimum segment size of the ARENA.
This value controls the size of the holes.
The default minimum segment size is 48 bytes.
§Example
use rarena_allocator::ArenaOptions;
let opts = ArenaOptions::new().with_minimum_segment_size(64);sourcepub const fn maximum_alignment(&self) -> usize
pub const fn maximum_alignment(&self) -> usize
Get the maximum alignment of the ARENA.
§Example
use rarena_allocator::ArenaOptions;
let opts = ArenaOptions::new().with_maximum_alignment(16);
assert_eq!(opts.maximum_alignment(), 16);sourcepub const fn capacity(&self) -> u32
pub const fn capacity(&self) -> u32
Get the capacity of the ARENA.
§Example
use rarena_allocator::ArenaOptions;
let opts = ArenaOptions::new().with_capacity(2048);
assert_eq!(opts.capacity(), 2048);sourcepub const fn minimum_segment_size(&self) -> u32
pub const fn minimum_segment_size(&self) -> u32
Get the minimum segment size of the ARENA.
§Example
use rarena_allocator::ArenaOptions;
let opts = ArenaOptions::new().with_minimum_segment_size(64);
assert_eq!(opts.minimum_segment_size(), 64);Trait Implementations§
source§impl Clone for ArenaOptions
impl Clone for ArenaOptions
source§fn clone(&self) -> ArenaOptions
fn clone(&self) -> ArenaOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more