Struct starlark::values::FrozenHeap

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

A heap on which FrozenValues can be allocated. Can be kept alive by a FrozenHeapRef.

Implementations§

source§

impl FrozenHeap

source

pub fn new() -> Self

Create a new FrozenHeap.

source

pub fn into_ref(self) -> FrozenHeapRef

After all values have been allocated, convert the FrozenHeap into a FrozenHeapRef which can be cloned, shared between threads, and ensures the underlying values allocated on the FrozenHeap remain valid.

source

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.

source

pub fn alloc_str(&self, x: &str) -> FrozenStringValue

Allocate a string on this heap. Be careful about the warnings around FrozenValue.

source

pub fn alloc_str_hashed(&self, x: Hashed<&str>) -> FrozenStringValue

Allocate prehashed string.

source

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

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.

source

pub fn alloc<T: AllocFrozenValue>(&self, val: T) -> FrozenValue

Allocate a new value on a FrozenHeap.

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 available_bytes(&self) -> usize

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

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 FrozenHeap

source§

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

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

impl Default for FrozenHeap

source§

fn default() -> FrozenHeap

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

Auto Trait Implementations§

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.