Trait timely::container::columnation::Region
source · pub trait Region: Default {
type Item;
// Required methods
unsafe fn copy(&mut self, item: &Self::Item) -> Self::Item;
fn clear(&mut self);
fn reserve_items<'a, I>(&mut self, items: I)
where Self: 'a,
I: Iterator<Item = &'a Self::Item> + Clone;
fn reserve_regions<'a, I>(&mut self, regions: I)
where Self: 'a,
I: Iterator<Item = &'a Self> + Clone;
fn heap_size(&self, callback: impl FnMut(usize, usize));
// Provided methods
fn with_capacity_items<'a, I>(items: I) -> Self
where Self: 'a,
I: Iterator<Item = &'a Self::Item> + Clone { ... }
fn with_capacity_regions<'a, I>(regions: I) -> Self
where Self: 'a,
I: Iterator<Item = &'a Self> + Clone { ... }
}
Expand description
A type that can absorb owned data from type T
.
This type will ensure that absorbed data remain valid as long as the
instance itself is valid. Responsible users will couple the lifetime
of this instance with that of all instances it returns from copy
.
Required Associated Types§
Required Methods§
sourceunsafe fn copy(&mut self, item: &Self::Item) -> Self::Item
unsafe fn copy(&mut self, item: &Self::Item) -> Self::Item
Add a new element to the region.
The argument will be copied in to the region and returned as an owned instance. It is unsafe to unwrap and then drop the result.
§Safety
It is unsafe to use the result in any way other than to reference its contents, and then only for the lifetime of the columnar region. Correct uses of this method are very likely exclusive to this crate.
sourcefn clear(&mut self)
fn clear(&mut self)
Retain allocations but discard their contents.
The elements in the region do not actually own resources, and
their normal Drop
implementations will not be called. This method
should only be called after all instances returned by copy
have
been disposed of, as this method may invalidate their contents.
sourcefn reserve_items<'a, I>(&mut self, items: I)
fn reserve_items<'a, I>(&mut self, items: I)
Ensure that the region can absorb items
without reallocation.
fn reserve_regions<'a, I>(&mut self, regions: I)
sourcefn heap_size(&self, callback: impl FnMut(usize, usize))
fn heap_size(&self, callback: impl FnMut(usize, usize))
Determine this region’s memory used and reserved capacity in bytes.
An implementation should invoke the callback
for each distinct allocation, providing the
used capacity as the first parameter and the actual capacity as the second parameter.
Both parameters represent a number of bytes. The implementation should only mention
allocations it owns, but not itself, because another object owns it.
The closure is free to sum the parameters, or do more advanced analysis such as creating a histogram of allocation sizes.
Provided Methods§
sourcefn with_capacity_items<'a, I>(items: I) -> Self
fn with_capacity_items<'a, I>(items: I) -> Self
Allocate an instance of Self
that can absorb items
without reallocation.
sourcefn with_capacity_regions<'a, I>(regions: I) -> Self
fn with_capacity_regions<'a, I>(regions: I) -> Self
Allocate an instance of Self
that can absorb the items of regions
without reallocation.