graphflo 0.1.0

The graphflo plugin for libflo.
Documentation
use { serde_json, string, util };
use libflo_error::{ Result as FuncResult, WrapErr };
use serialization::{ func, dynamic_event };
use static_libflo::{ STATIC_LIBFLO };

#[no_mangle]
pub extern fn connect_nodes(arg: &str) -> FuncResult<()> {
    let libflo = STATIC_LIBFLO.get().wrap_err_to_err()?;
    let mut this = util::get_this_mut(&libflo).wrap_err_to_err()?;
    let this = util::cast_this_mut(&mut this).wrap_err_to_err()?;

    let arg = serde_json::from_str::<func::ConnectNodesArg>(arg).wrap_err_to_err()?;

    this.get_graph_mut().wrap_err_to_err()?.connect_nodes(
        arg.start_connector_index,
        arg.finish_connector_index
    ).wrap_err_to_err()?;

    let result = dynamic_event::ConnectNodesArg::new(
        arg.start_connector_index,
        arg.finish_connector_index
    );

    libflo.send_event_by_module_name(
        string::self_module_name(),
        string::connect_nodes(),
        &result
    ).wrap_err_to_err()
}