pub struct Heap { /* private fields */ }
Expand description
A heap on which Value
s can be allocated. The values will be annotated with the heap lifetime.
Implementations§
source§impl Heap
impl Heap
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 peak_allocated_bytes(&self) -> usize
pub fn peak_allocated_bytes(&self) -> usize
Peak memory allocated to this heap, even if the value is now lower as a result of a subsequent garbage collection.
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 alloc_str<'v>(&'v self, x: &str) -> StringValue<'v>
pub fn alloc_str<'v>(&'v self, x: &str) -> StringValue<'v>
Allocate a string on the heap.
sourcepub fn alloc_str_concat<'v>(&'v self, x: &str, y: &str) -> StringValue<'v>
pub fn alloc_str_concat<'v>(&'v self, x: &str, y: &str) -> StringValue<'v>
Allocate a string on the heap, based on two concatenated strings.
sourcepub fn alloc_str_concat3<'v>(
&'v self,
x: &str,
y: &str,
z: &str
) -> StringValue<'v>
pub fn alloc_str_concat3<'v>( &'v self, x: &str, y: &str, z: &str ) -> StringValue<'v>
Allocate a string on the heap, based on three concatenated strings.
sourcepub fn alloc_simple<'v, T: StarlarkValue<'static> + Send + Sync>(
&'v self,
x: T
) -> Value<'v>
pub fn alloc_simple<'v, T: StarlarkValue<'static> + Send + Sync>( &'v self, x: T ) -> Value<'v>
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
)
Must be Send
and Sync
because it will be reused in frozen values.
sourcepub fn alloc_complex<'v, T>(&'v self, x: T) -> Value<'v>
pub fn alloc_complex<'v, T>(&'v self, x: T) -> Value<'v>
Allocate a ComplexValue
on the Heap
.
sourcepub fn alloc_complex_no_freeze<'v, T>(&'v self, x: T) -> Value<'v>where
T: StarlarkValue<'v> + Trace<'v>,
pub fn alloc_complex_no_freeze<'v, T>(&'v self, x: T) -> Value<'v>where
T: StarlarkValue<'v> + Trace<'v>,
Allocate a value which can be traced (garbage collected), but cannot be frozen.
sourcepub fn alloc<'v, T: AllocValue<'v>>(&'v self, x: T) -> Value<'v>
pub fn alloc<'v, T: AllocValue<'v>>(&'v self, x: T) -> Value<'v>
Allocate a new value on a Heap
.
sourcepub fn alloc_typed<'v, T: AllocValue<'v> + StarlarkValue<'v>>(
&'v self,
x: T
) -> ValueTyped<'v, T>
pub fn alloc_typed<'v, T: AllocValue<'v> + StarlarkValue<'v>>( &'v self, x: T ) -> ValueTyped<'v, T>
Allocate a value and return ValueTyped
of it.
Can fail if the AllocValue
trait generates a different type on the heap.
sourcepub fn alloc_value_of<'v, T>(&'v self, x: T) -> ValueOf<'v, &'v T>
pub fn alloc_value_of<'v, T>(&'v self, x: T) -> ValueOf<'v, &'v T>
Allocate a value and return ValueOf
of it.
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.