pub struct Program<'p> { /* private fields */ }Expand description
Jsonnet program state and evaluator.
See the module-level documentation for more information.
Implementations§
Source§impl<'p> Program<'p>
impl<'p> Program<'p>
pub fn str_interner(&self) -> &StrInterner<'p>
pub fn intern_str(&self, s: &str) -> InternedStr<'p>
pub fn span_manager(&self) -> &SpanManager
pub fn span_manager_mut(&mut self) -> &mut SpanManager
Sourcepub fn set_max_stack(&mut self, max_stack: usize)
pub fn set_max_stack(&mut self, max_stack: usize)
Sets the maximum call stack size.
The default is 500.
Sourcepub fn get_stdlib_source(&self) -> (SourceId, &[u8])
pub fn get_stdlib_source(&self) -> (SourceId, &[u8])
Returns the source of the part of the standard library that is implemented in Jsonnet.
Sourcepub fn add_ext_var(&mut self, name: InternedStr<'p>, thunk: &Thunk<'p>)
pub fn add_ext_var(&mut self, name: InternedStr<'p>, thunk: &Thunk<'p>)
Adds an external variable.
External variables can be accessed within a Jsonnet program
with the std.extVar function.
Sourcepub fn register_native_func(
&mut self,
name: InternedStr<'p>,
params: &[InternedStr<'p>],
)
pub fn register_native_func( &mut self, name: InternedStr<'p>, params: &[InternedStr<'p>], )
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.
§Panics
Panics if a native function with the same name is already registered or if a parameter name is repeated.
Sourcepub fn value_to_thunk(&mut self, value: &Value<'p>) -> Thunk<'p>
pub fn value_to_thunk(&mut self, value: &Value<'p>) -> Thunk<'p>
Creates a thunk with an already evaluated value.
Sourcepub fn make_array(&mut self, items: &[Value<'p>]) -> Value<'p>
pub fn make_array(&mut self, items: &[Value<'p>]) -> Value<'p>
Creates an array value.
Sourcepub fn make_object(
&mut self,
obj_fields: &[(InternedStr<'p>, Value<'p>)],
) -> Value<'p>
pub fn make_object( &mut self, obj_fields: &[(InternedStr<'p>, Value<'p>)], ) -> Value<'p>
Creates an object value.
Sourcepub fn load_source(
&mut self,
span_ctx: SpanContextId,
input: &[u8],
with_stdlib: bool,
this_file: &str,
) -> Result<Thunk<'p>, LoadError>
pub fn load_source( &mut self, span_ctx: SpanContextId, input: &[u8], with_stdlib: bool, this_file: &str, ) -> Result<Thunk<'p>, 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.
Sourcepub fn eval_value(
&mut self,
thunk: &Thunk<'p>,
callbacks: &mut dyn Callbacks<'p>,
) -> Result<Value<'p>, EvalError>
pub fn eval_value( &mut self, thunk: &Thunk<'p>, callbacks: &mut dyn Callbacks<'p>, ) -> Result<Value<'p>, EvalError>
Evaluates a thunk into a value.