graphy_shared_funcs 0.3.0

Shared funcs for graphy.
use error::*;
use graphy_dll_error::Result as FuncResult;
use graphy_dll_error::WrapErr;
use graphy_dll_error::WrapError;
use graphy_environment::Environment;
use graphy_static::ENVIRONMENT;
use std::any::Any;
use std::sync::Arc;

#[no_mangle]
pub fn construct(environment: &Any) -> FuncResult<()> {
    let environment: Option<&Arc<Environment>> = environment.downcast_ref();
    if let Some(environment) = environment {
        let environment = environment.clone();
        try!(ENVIRONMENT.set(environment).wrap_err_to_err());
    } else {
        let err: Error = ErrorKind::ConstructEventNotPassedEnvironment.into();
        return err.wrap_error_to_err();
    }

    Ok(())
}