Skip to main content

interpret_streaming

Function interpret_streaming 

Source
pub async fn interpret_streaming<F>(
    input: &str,
    on_output: Rc<RefCell<F>>,
) -> InterpreterResult
where F: FnMut(String) + 'static,
Expand description

Interpret LOGOS imperative code with streaming output.

The on_output callback is called each time Show executes, allowing real-time output display like a REPL. The callback receives the output line.

ยงExample

use std::rc::Rc;
use std::cell::RefCell;

let lines = Rc::new(RefCell::new(Vec::new()));
let lines_clone = lines.clone();

interpret_streaming(source, Rc::new(RefCell::new(move |line: String| {
    lines_clone.borrow_mut().push(line);
}))).await;