2019-01-26 14:08:02 +00:00
|
|
|
use crate::api::router::*;
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use serde_json::Value;
|
|
|
|
|
|
|
|
pub struct RestEnvironment {
|
2019-01-27 09:33:42 +00:00
|
|
|
env_type: RpcEnvironmentType,
|
2019-01-26 14:08:02 +00:00
|
|
|
result_attributes: HashMap<String, Value>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RestEnvironment {
|
2019-01-27 09:33:42 +00:00
|
|
|
pub fn new(env_type: RpcEnvironmentType) -> Self {
|
|
|
|
Self {
|
|
|
|
result_attributes: HashMap::new(),
|
|
|
|
env_type,
|
|
|
|
}
|
2019-01-26 14:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RpcEnvironment for RestEnvironment {
|
|
|
|
|
|
|
|
fn set_result_attrib(&mut self, name: &str, value: Value) {
|
|
|
|
self.result_attributes.insert(name.into(), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_result_attrib(&self, name: &str) -> Option<&Value> {
|
|
|
|
self.result_attributes.get(name)
|
|
|
|
}
|
2019-01-27 09:33:42 +00:00
|
|
|
|
|
|
|
fn env_type(&self) -> RpcEnvironmentType {
|
|
|
|
self.env_type
|
|
|
|
}
|
2019-01-26 14:08:02 +00:00
|
|
|
}
|