1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
extern crate cfg_if; cfg_if::cfg_if! { if #[cfg(feature = "arcon_spec")] { pub mod arcon_spec { include!(concat!(env!("OUT_DIR"), "/arcon_spec.rs")); use failure::Fail; use arcon_spec::Mode; #[derive(Debug, Fail)] #[fail(display = "Loading spec err: `{}`", msg)] pub struct SpecError { msg: String, } pub fn spec_from_file(path: &str) -> Result<ArconSpec, SpecError> { let file = std::fs::File::open(path).map_err(|e| SpecError { msg: e.to_string() })?; serde_json::from_reader(file).map_err(|e| SpecError { msg: e.to_string() }) } pub fn spec_from_bytes(bytes: &[u8]) -> Result<ArconSpec, SpecError> { serde_json::from_slice(bytes).map_err(|e| SpecError { msg: e.to_string() }) } pub fn get_compile_mode(spec: &ArconSpec) -> String { match spec.mode.as_ref() { Some(Mode::Debug(_)) => "debug".to_string(), Some(Mode::Release(_)) => "release".to_string(), None => "release".to_string(), } } } } } cfg_if::cfg_if! { if #[cfg(feature = "arconc")] { pub mod proto { include!(concat!(env!("OUT_DIR"), "/mod.rs")); } pub use proto::arconc::*; pub use proto::arconc_grpc::*; } }