use { string, util };
use libflo_error::{ Result as FuncResult, WrapErr };
use serialization::{ KeyedNodeDesc, NodeDesc };
use static_libflo::STATIC_LIBFLO;
#[no_mangle]
pub extern fn get_resources() -> FuncResult<()> {
let libflo = STATIC_LIBFLO.get().wrap_err_to_err()?;
let this = util::get_this(&libflo).wrap_err_to_err()?;
let this = util::cast_this(&this).wrap_err_to_err()?;
let node_descriptions = this.get_node_descriptions().wrap_err_to_err()?;
let node_descriptions_ref: &Vec<NodeDesc> = node_descriptions.as_ref();
let result: Vec<_> = node_descriptions_ref
.into_iter()
.enumerate()
.map(
|(index, desc)| KeyedNodeDesc::new(index, desc.clone())
).collect();
libflo.send_event_by_module_name(
string::self_module_name(),
string::get_resources(),
&result
).wrap_err_to_err()
}