pub trait MemConfig {
// Required methods
fn new() -> Self;
fn debug_assert_config();
fn capacity(&self, segments: usize) -> usize;
fn segment_size(&self, segment: usize) -> usize;
fn segment_and_offset(&self, index: usize) -> (usize, usize);
// Provided method
fn update_capacity(&mut self, _segments: usize) { ... }
}
Expand description
Configures the sizes of segments and how to index entries. Linear
, Proportional
and
Exponential
implement this trait.
Required Methods§
fn new() -> Self
sourcefn debug_assert_config()
fn debug_assert_config()
Called by ctors to assert that the configuration is valid.
Some MemConfig
implementations may put constraints on (const generic)
parameters. Currently it is impossible to assert these at compile time in stable
rust. In debug builds we check these constraints when a SegVec
uses some
config. The three shipped MemConfig
implementations check here that the ‘FACTOR’ is
not zero.
sourcefn capacity(&self, segments: usize) -> usize
fn capacity(&self, segments: usize) -> usize
Takes the number of allocated segments, returns the total capacity.
sourcefn segment_size(&self, segment: usize) -> usize
fn segment_size(&self, segment: usize) -> usize
Returns the size of the nth segment (starting at 0).
sourcefn segment_and_offset(&self, index: usize) -> (usize, usize)
fn segment_and_offset(&self, index: usize) -> (usize, usize)
Translates a flat index into (segment, offset)
Provided Methods§
sourcefn update_capacity(&mut self, _segments: usize)
fn update_capacity(&mut self, _segments: usize)
Updates the capacity to the given number of segments.