Struct starlark::values::FrozenHeap
source · pub struct FrozenHeap { /* private fields */ }
Expand description
A heap on which FrozenValue
s can be allocated.
Can be kept alive by a FrozenHeapRef
.
Implementations§
source§impl FrozenHeap
impl FrozenHeap
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new FrozenHeap
.
sourcepub fn into_ref(self) -> FrozenHeapRef
pub fn into_ref(self) -> FrozenHeapRef
After all values have been allocated, convert the FrozenHeap
into a
FrozenHeapRef
which can be clone
d, shared between threads,
and ensures the underlying values allocated on the FrozenHeap
remain valid.
sourcepub fn add_reference(&self, heap: &FrozenHeapRef)
pub fn add_reference(&self, heap: &FrozenHeapRef)
Keep the argument FrozenHeapRef
alive as long as this FrozenHeap
is kept alive. Used if a FrozenValue
in this heap points at values in another
FrozenHeap
.
sourcepub fn alloc_str(&self, x: &str) -> FrozenStringValue
pub fn alloc_str(&self, x: &str) -> FrozenStringValue
Allocate a string on this heap. Be careful about the warnings
around FrozenValue
.
sourcepub fn alloc_str_hashed(&self, x: Hashed<&str>) -> FrozenStringValue
pub fn alloc_str_hashed(&self, x: Hashed<&str>) -> FrozenStringValue
Allocate prehashed string.
sourcepub fn alloc_simple<T: StarlarkValue<'static> + Send + Sync>(
&self,
val: T
) -> FrozenValue
pub fn alloc_simple<T: StarlarkValue<'static> + Send + Sync>( &self, val: T ) -> FrozenValue
Allocate a simple StarlarkValue
on this heap.
Simple value is any starlark value which:
- bound by
'static
lifetime (in particular, it cannot contain references to otherValue
s) - is not special builtin (e.g.
None
)
sourcepub fn alloc_any_display_from_debug<T: Debug + Send + Sync>(
&self,
value: T
) -> FrozenRef<'static, T>
pub fn alloc_any_display_from_debug<T: Debug + Send + Sync>( &self, value: T ) -> FrozenRef<'static, T>
Allocate any value, use Debug
implementation for Display
.
sourcepub fn alloc<T: AllocFrozenValue>(&self, val: T) -> FrozenValue
pub fn alloc<T: AllocFrozenValue>(&self, val: T) -> FrozenValue
Allocate a new value on a FrozenHeap
.
sourcepub fn allocated_bytes(&self) -> usize
pub fn allocated_bytes(&self) -> usize
Number of bytes allocated on this heap, not including any memory allocated outside of the starlark heap.
sourcepub fn available_bytes(&self) -> usize
pub fn available_bytes(&self) -> usize
Number of bytes allocated by the heap but not yet filled.
sourcepub fn allocated_summary(&self) -> HeapSummary
pub fn allocated_summary(&self) -> HeapSummary
Obtain a summary of how much memory is currently allocated by this heap.