Struct rsjsonnet_lang::program::Program
source · pub struct Program { /* private fields */ }Expand description
Jsonnet program state and evaluator.
Implementations§
source§impl Program
impl Program
pub fn str_interner(&self) -> &StrInterner
pub fn span_manager(&self) -> &SpanManager
pub fn span_manager_mut(&mut self) -> &mut SpanManager
pub fn set_max_stack(&mut self, max_stack: usize)
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, thunk: &Thunk)
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.
sourcepub fn register_native_func(
&mut self,
name: InternedStr,
params: &[InternedStr]
)
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.
sourcepub fn value_to_thunk(&mut self, value: &Value) -> Thunk
pub fn value_to_thunk(&mut self, value: &Value) -> Thunk
Creates a thunk with an already evaluated value.
sourcepub fn make_array(&mut self, items: &[Value]) -> Value
pub fn make_array(&mut self, items: &[Value]) -> Value
Creates an array value.
sourcepub fn make_object(&mut self, obj_fields: &[(InternedStr, Value)]) -> Value
pub fn make_object(&mut self, obj_fields: &[(InternedStr, Value)]) -> Value
Creates an object value.
sourcepub fn load_source(
&mut self,
span_ctx: SpanContextId,
input: &[u8],
with_stdlib: bool,
this_file: &str
) -> Result<Thunk, LoadError>
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.
sourcepub fn eval_value(
&mut self,
thunk: &Thunk,
callbacks: &mut dyn Callbacks
) -> Result<Value, EvalError>
pub fn eval_value( &mut self, thunk: &Thunk, callbacks: &mut dyn Callbacks ) -> Result<Value, EvalError>
Evaluates a thunk into a value.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more