Struct rsjsonnet_lang::program::Program

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

Jsonnet program state and evaluator.

See the module-level documentation for more information.

Implementations§

source§

impl Program

source

pub fn new() -> Self

Creates a new Program.

source

pub fn str_interner(&self) -> &StrInterner

source

pub fn span_manager(&self) -> &SpanManager

source

pub fn span_manager_mut(&mut self) -> &mut SpanManager

source

pub fn gc(&mut self)

Runs garbage collection unconditionally.

source

pub fn maybe_gc(&mut self)

Runs garbage collection under certain conditions.

source

pub fn set_max_stack(&mut self, max_stack: usize)

Sets the maximum call stack size.

The default is 500.

source

pub fn get_stdlib_source(&self) -> (SourceId, &[u8])

Returns the source of the part of the standard library that is implemented in Jsonnet.

source

pub fn add_ext_var(&mut self, name: InternedStr, thunk: &Thunk)

Adds an external variable.

External variables can be accessed within a Jsonnet program with the std.extVar function.

source

pub fn register_native_func( &mut self, name: InternedStr, params: &[InternedStr], )

Registers a native function.

Native functions can be accessed within a Jsonnet program with the std.native function.

The actual behavior of the native function should be implemented in Callbacks::native_call.

source

pub fn value_to_thunk(&mut self, value: &Value) -> Thunk

Creates a thunk with an already evaluated value.

source

pub fn make_array(&mut self, items: &[Value]) -> Value

Creates an array value.

source

pub fn make_object(&mut self, obj_fields: &[(InternedStr, Value)]) -> Value

Creates an object value.

source

pub fn load_source( &mut self, span_ctx: SpanContextId, input: &[u8], with_stdlib: bool, this_file: &str, ) -> Result<Thunk, LoadError>

Loads a Jsonnet source into a thunk.

with_stdlib specifies whether the standard library will be available as std. this_file will be the value of std.thisFile.

source

pub fn eval_value( &mut self, thunk: &Thunk, callbacks: &mut dyn Callbacks, ) -> Result<Value, EvalError>

Evaluates a thunk into a value.

source

pub fn eval_call( &mut self, func: &Thunk, pos_args: &[Thunk], named_args: &[(InternedStr, Thunk)], callbacks: &mut dyn Callbacks, ) -> Result<Value, EvalError>

Evaluates a function call.

source

pub fn manifest_json( &mut self, value: &Value, multiline: bool, ) -> Result<String, EvalError>

Manifests a value as JSON.

Trait Implementations§

source§

impl Default for Program

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Program

§

impl !RefUnwindSafe for Program

§

impl !Send for Program

§

impl !Sync for Program

§

impl Unpin for Program

§

impl !UnwindSafe for Program

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> Same for T

§

type Output = T

Should always be 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.