flowstdlib 1.0.0

The standard library of functions and flows for 'flow' programs
Documentation
#[doc = include_str!("multiply.md")]
#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
mod test {
    use std::fs::File;
    use std::io::Write;

    use serial_test::serial;
    use tempfile::tempdir;

    use super::super::super::test::execute_flow;

    // Serialized to avoid mDNS service name collision when multiple flowc
    // instances run in parallel — see https://github.com/andrewdavidmackenzie/flow/issues/2563
    #[test]
    #[serial]
    fn test_multiply_flow() {
        let flow = "\
flow = \"matrix_multiply_test\"

[[process]]
source = \"lib://flowstdlib/matrix/multiply\"
input.a = { once = [[1,2],[3,4]] }
input.b = { once = [[5,6],[7,8]] }

[[process]]
source = \"context://stdio/stdout\"

[[connection]]
from = \"multiply/product\"
to = \"stdout\"
";

        let temp_dir = tempdir()
            .expect("Could not create temporary directory")
            .keep();
        let flow_filename = temp_dir.join("matrix_multiply_test.toml");
        let mut flow_file =
            File::create(&flow_filename).expect("Could not create lib manifest file");
        flow_file
            .write_all(flow.as_bytes())
            .expect("Could not write data bytes to created flow file");

        let stdout = execute_flow(&flow_filename);
        assert_eq!(stdout, "[[19,22],[43,50]]\n".to_string());
    }
}