pub struct Engine { /* private fields */ }Expand description
The public embedding API for the Ion interpreter.
Implementations§
Source§impl Engine
impl Engine
pub fn new() -> Self
Sourcepub fn eval(&mut self, source: &str) -> Result<Value, IonError>
pub fn eval(&mut self, source: &str) -> Result<Value, IonError>
Evaluate a script, returning the last expression’s value.
Sourcepub fn set_limits(&mut self, limits: Limits)
pub fn set_limits(&mut self, limits: Limits)
Set execution limits.
Sourcepub fn register_fn(
&mut self,
name: &str,
func: fn(&[Value]) -> Result<Value, String>,
)
pub fn register_fn( &mut self, name: &str, func: fn(&[Value]) -> Result<Value, String>, )
Register a built-in function.
Sourcepub fn register_closure<F>(&mut self, name: &str, func: F)
pub fn register_closure<F>(&mut self, name: &str, func: F)
Register a built-in backed by a closure. Unlike register_fn,
this accepts any Fn — including closures that capture
host-side state such as a tokio::runtime::Handle, a database
pool, or shared counters. See docs/concurrency.md for the
tokio embedding pattern.
Sourcepub fn register_struct(&mut self, def: HostStructDef)
pub fn register_struct(&mut self, def: HostStructDef)
Register a host struct type that scripts can construct and match on.
Sourcepub fn register_enum(&mut self, def: HostEnumDef)
pub fn register_enum(&mut self, def: HostEnumDef)
Register a host enum type that scripts can construct and match on.
Sourcepub fn register_module(&mut self, module: Module)
pub fn register_module(&mut self, module: Module)
Register a module that scripts can access via module::name or use module::*.
Sourcepub fn register_type<T: IonType>(&mut self)
pub fn register_type<T: IonType>(&mut self)
Register a type via the IonType trait (used with #[derive(IonType)]).
Sourcepub fn set_typed<T: IonType>(&mut self, name: &str, value: &T)
pub fn set_typed<T: IonType>(&mut self, name: &str, value: &T)
Inject a typed Rust value into the script scope.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl !UnwindSafe for Engine
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