subspace 0.1.0

A convenience crate for IPC, using TcpStreams
Documentation
  • Coverage
  • 0%
    0 out of 33 items documented0 out of 20 items with examples
  • Size
  • Source code size: 26.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.84 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 24s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Documentation
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rhvdpols

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

[dependencies]

subspace = "0.1.0"

In your main process, create an External struct.

    // 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.

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::with_name("addr")
                .short("a")
                .long("addr")
                .help("Address this node should bind to")
                .takes_value(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.