pub struct Kinetik { /* private fields */ }Expand description
Embedded Kinetik runtime.
Implementations§
Source§impl Kinetik
impl Kinetik
Sourcepub fn register_native<F>(&mut self, name: impl Into<String>, function: F)
pub fn register_native<F>(&mut self, name: impl Into<String>, function: F)
Registers a host-native function in the root environment.
Sourcepub fn insert_host<T>(&mut self, value: T) -> Value
pub fn insert_host<T>(&mut self, value: T) -> Value
Stores a host-owned object and returns an opaque script value for it.
Sourcepub fn remove_host(&mut self, value: &Value) -> Result<()>
pub fn remove_host(&mut self, value: &Value) -> Result<()>
Removes a host-owned object, making existing handles stale.
§Errors
Returns a stale handle error when the value is not a live host handle.
Sourcepub fn with_host<T, R>(
&self,
value: &Value,
read: impl FnOnce(&T) -> R,
) -> Result<R>
pub fn with_host<T, R>( &self, value: &Value, read: impl FnOnce(&T) -> R, ) -> Result<R>
Accesses a host object through a closure without exposing raw references.
§Errors
Returns a stale handle or type mismatch error when the handle is invalid.
Sourcepub fn with_host_mut<T, R>(
&mut self,
value: &Value,
write: impl FnOnce(&mut T) -> R,
) -> Result<R>
pub fn with_host_mut<T, R>( &mut self, value: &Value, write: impl FnOnce(&mut T) -> R, ) -> Result<R>
Mutates a host object through a closure without exposing raw references.
§Errors
Returns a stale handle or type mismatch error when the handle is invalid.
Sourcepub fn define_global(&mut self, name: impl Into<String>, value: Value)
pub fn define_global(&mut self, name: impl Into<String>, value: Value)
Defines a global script value.
Sourcepub fn load_source(
&mut self,
name: impl Into<String>,
text: impl Into<String>,
) -> Result<Value>
pub fn load_source( &mut self, name: impl Into<String>, text: impl Into<String>, ) -> Result<Value>
Loads, parses, and evaluates a Kinetik source string.
§Errors
Returns parse diagnostics or a runtime error when script loading fails.
Sourcepub fn reload_source(
&mut self,
name: impl Into<String>,
text: impl Into<String>,
) -> Result<ReloadReport>
pub fn reload_source( &mut self, name: impl Into<String>, text: impl Into<String>, ) -> Result<ReloadReport>
Parses and reloads a Kinetik source string into the running runtime.
Parse errors are reported before the current runtime is mutated, so the previously loaded script functions remain callable after a bad edit.
§Errors
Returns parse diagnostics or a runtime error when script reloading fails.
Sourcepub fn load_file(&mut self, path: impl AsRef<Path>) -> Result<Value>
pub fn load_file(&mut self, path: impl AsRef<Path>) -> Result<Value>
Loads, parses, and evaluates a Kinetik script file.
§Errors
Returns I/O, parse, or runtime errors when script loading fails.
Sourcepub fn call_function(
&mut self,
name: &str,
args: &[Value],
) -> Result<Vec<Value>>
pub fn call_function( &mut self, name: &str, args: &[Value], ) -> Result<Vec<Value>>
Calls a named script or native function.
§Errors
Returns an error when the function is missing, not callable, or fails.
Sourcepub fn drain_output(&mut self) -> impl Iterator<Item = String> + '_
pub fn drain_output(&mut self) -> impl Iterator<Item = String> + '_
Drains lines produced by the default standard-library print function.