Skip to main content

Kinetik

Struct Kinetik 

Source
pub struct Kinetik { /* private fields */ }
Expand description

Embedded Kinetik runtime.

Implementations§

Source§

impl Kinetik

Source

pub fn new() -> Self

Creates a new embedded runtime.

Source

pub fn register_native<F>(&mut self, name: impl Into<String>, function: F)
where F: Fn(&[Value]) -> HostNativeResult + Send + Sync + 'static,

Registers a host-native function in the root environment.

Source

pub fn insert_host<T>(&mut self, value: T) -> Value
where T: Any + Send + Sync + 'static,

Stores a host-owned object and returns an opaque script value for it.

Source

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.

Source

pub fn with_host<T, R>( &self, value: &Value, read: impl FnOnce(&T) -> R, ) -> Result<R>
where T: Any + Send + Sync + 'static,

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.

Source

pub fn with_host_mut<T, R>( &mut self, value: &Value, write: impl FnOnce(&mut T) -> R, ) -> Result<R>
where T: Any + Send + Sync + 'static,

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.

Source

pub fn define_global(&mut self, name: impl Into<String>, value: Value)

Defines a global script value.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get(&self, name: &str) -> Option<Value>

Reads a global value from the embedded runtime.

Source

pub fn drain_output(&mut self) -> impl Iterator<Item = String> + '_

Drains lines produced by the default standard-library print function.

Trait Implementations§

Source§

impl Debug for Kinetik

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Kinetik

Source§

fn default() -> Self

Returns the “default value” for a type. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.