pub struct GlobalsBuilder { /* private fields */ }
Expand description

Used to build a Globals value.

Implementations§

source§

impl GlobalsBuilder

source

pub fn new() -> Self

Create an empty GlobalsBuilder, with no functions in scope.

source

pub fn standard() -> Self

Create a GlobalsBuilder following the Starlark standard.

source

pub fn extended_by(extensions: &[LibraryExtension]) -> Self

Create a GlobalsBuilder combining those functions in the Starlark standard plus all those defined in LibraryExtension.

source

pub fn struct_(&mut self, name: &str, f: impl FnOnce(&mut GlobalsBuilder))

Add a nested struct to the builder. If f adds the definition foo, it will end up on a struct name, accessible as name.foo.

source

pub fn with(self, f: impl FnOnce(&mut Self)) -> Self

A fluent API for modifying GlobalsBuilder and returning the result.

source

pub fn with_struct(self, name: &str, f: impl Fn(&mut GlobalsBuilder)) -> Self

A fluent API for modifying GlobalsBuilder using struct_.

source

pub fn build(self) -> Globals

Called at the end to build a Globals.

source

pub fn set<'v, V: AllocFrozenValue>(&'v mut self, name: &str, value: V)

Set a value in the GlobalsBuilder.

source

pub fn set_function<F>( &mut self, name: &str, speculative_exec_safe: bool, raw_docs: NativeCallableRawDocs, type_attr: Option<Ty>, ty: Option<Ty>, special_builtin_function: Option<SpecialBuiltinFunction>, f: F )
where F: NativeFunc,

Set a method. This function is usually called from code generated by starlark_derive and rarely needs to be called manually.

source

pub fn frozen_heap(&self) -> &FrozenHeap

Heap where globals are allocated. Can be used to allocate additional values.

source

pub fn alloc<'v, V: AllocFrozenValue>(&'v self, value: V) -> FrozenValue

Allocate a value using the same underlying heap as the GlobalsBuilder, only intended for values that are referred to by those which are passed to set.

source

pub fn set_docstring(&mut self, docstring: &str)

Set per module docstring.

This function is called by the starlark_derive generated code and rarely needs to be called manually.

Trait Implementations§

source§

impl Debug for GlobalsBuilder

source§

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

Formats the value using the given formatter. 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.