githubEdit

Custom Embedded

Embed Stof within Rust on your own terms.

Stof is meant to be embeddable within the environment of your choice. Because it is written in Rust, we'll give a brief Rust overview here. Take a look at the source codearrow-up-right or cratearrow-up-right for more information.

circle-info

We're adding more embedded environments - if language interop is interesting to you, please get involved.

use stof::model::Graph;

/// This is Rust now, not Stof.
fn main() {
    let mut graph = Graph::default();
    
    graph.parse_stof_src(r#"
        message: "Hello, world!"
        
        #[main]
        fn main() {
            pln(self.message);
        }
    "#, None).expect("error parsing Stof");
    
    // this will run all #[main] functions
    // can always call functions individually with graph.call(..)
    match graph.run(None, true) {
        Ok(res) => println!("{res}"),
        Err(res) => println!("{res}"),
    }
}

Sandboxing

Stof interfaces with the outside world through libraries and formats only. A library is just a map of LibFunc implementations, so you can partially remove, replace, extend, etc., any library of your choice. The same goes for formats, where you can import or export data as you wish, either from Stof or Rust.

Last updated