proxmox-backup/src/server/environment.rs

34 lines
739 B
Rust
Raw Normal View History

use crate::api::router::*;
use std::collections::HashMap;
use serde_json::Value;
pub struct RestEnvironment {
env_type: RpcEnvironmentType,
result_attributes: HashMap<String, Value>,
}
impl RestEnvironment {
pub fn new(env_type: RpcEnvironmentType) -> Self {
Self {
result_attributes: HashMap::new(),
env_type,
}
}
}
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)
}
fn env_type(&self) -> RpcEnvironmentType {
self.env_type
}
}