subspace

subspace is a highly unstable convenience crate for setting up management of and communication with external processes (nodes).

Example

Add subspace to your Cargo.toml

toml [dependencies] subspace = "0.1.0"

In your main process, create an External struct.

```rust // For the full example, check tests/node_tests.rs

// name is the path + filename of the executable to launch
let name = "target/debug/example";

// address is the hostname + port the node should bind to
let address = "localhost:2345";

External::new(&name, address.to_string())?;

```

In your secondary process, parse command line arguments (done with clap in the example) and create a node.

```rust fn main() { // Commandline arguments handled with clap, External will call the executable with --addr localhost:2345 // let matches = App::new("Subspace example node") .author("ron") .about("An example process for subspace integration tests") .version("0.1") .arg( Arg::withname("addr") .short("a") .long("addr") .help("Address this node should bind to") .takesvalue(true), ) .get_matches();

// get address to bind to from arguments, then construct "this node"
//
let addr = matches.value_of("addr").unwrap();
let mut node = Node::new(addr).unwrap();

// call node.get_node_message() in this executables message loop, and act on it
//
loop {
    match node.get_node_message() {
        Some(NodeMessage::Exit) => break,
        _ => (),
    }

    // do work
}

} ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.