Struct starlark::values::Heap

source ·
pub struct Heap { /* private fields */ }
Expand description

A heap on which Values can be allocated. The values will be annotated with the heap lifetime.

Implementations§

source§

impl Heap

source

pub fn new() -> Self

Create a new Heap.

source

pub fn allocated_bytes(&self) -> usize

Number of bytes allocated on this heap, not including any memory allocated outside of the starlark heap.

source

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.

source

pub fn available_bytes(&self) -> usize

Number of bytes allocated by the heap but not yet filled.

source

pub fn alloc_str<'v>(&'v self, x: &str) -> StringValue<'v>

Allocate a string on the heap.

source

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.

source

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.

source

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 other Values)
  • is not special builtin (e.g. None)

Must be Send and Sync because it will be reused in frozen values.

source

pub fn alloc_complex<'v, T>(&'v self, x: T) -> Value<'v>
where T: ComplexValue<'v>, T::Frozen: StarlarkValue<'static>,

Allocate a ComplexValue on the Heap.

source

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.

source

pub fn alloc<'v, T: AllocValue<'v>>(&'v self, x: T) -> Value<'v>

Allocate a new value on a Heap.

source

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.

source

pub fn alloc_value_of<'v, T>(&'v self, x: T) -> ValueOf<'v, &'v T>
where T: AllocValue<'v>, &'v T: UnpackValue<'v>,

Allocate a value and return ValueOf of it.

source

pub fn allocated_summary(&self) -> HeapSummary

Obtain a summary of how much memory is currently allocated by this heap.

Trait Implementations§

source§

impl Debug for Heap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Heap

source§

fn default() -> Heap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Heap

§

impl Send for Heap

§

impl !Sync for Heap

§

impl Unpin for Heap

§

impl !UnwindSafe for Heap

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToAst for T

source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.