pub struct Runtime { /* private fields */ }Expand description
The runtime environment for executing Patchwork code.
Holds variable bindings and execution context like the working directory.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(working_dir: PathBuf) -> Self
pub fn new(working_dir: PathBuf) -> Self
Create a new runtime with the given working directory.
Sourcepub fn with_print_sink(working_dir: PathBuf, print_sink: PrintSink) -> Self
pub fn with_print_sink(working_dir: PathBuf, print_sink: PrintSink) -> Self
Create a new runtime with a print sink for output redirection.
Sourcepub fn set_print_sink(&mut self, sink: PrintSink)
pub fn set_print_sink(&mut self, sink: PrintSink)
Set the print sink for output redirection.
Sourcepub fn print(&self, message: String) -> Result<(), String>
pub fn print(&self, message: String) -> Result<(), String>
Send a print message to the sink, or stdout if no sink is configured.
Returns Ok(()) on success, or Err if the channel is disconnected.
Sourcepub fn working_dir(&self) -> &PathBuf
pub fn working_dir(&self) -> &PathBuf
Get the current working directory.
Sourcepub fn set_working_dir(&mut self, dir: PathBuf)
pub fn set_working_dir(&mut self, dir: PathBuf)
Set the current working directory.
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Push a new scope onto the scope stack (entering a block).
Sourcepub fn define_var(&mut self, name: &str, value: Value) -> Result<(), String>
pub fn define_var(&mut self, name: &str, value: Value) -> Result<(), String>
Define a new variable in the current scope.
Returns an error if the variable already exists in the current scope.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Runtime
impl RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
impl UnwindSafe for Runtime
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