]> git.proxmox.com Git - proxmox-backup.git/blob - src/server/environment.rs
rename src/api to src/api_schema
[proxmox-backup.git] / src / server / environment.rs
1 use crate::api_schema::router::*;
2
3 use std::collections::HashMap;
4 use serde_json::Value;
5
6 pub struct RestEnvironment {
7 env_type: RpcEnvironmentType,
8 result_attributes: HashMap<String, Value>,
9 user: Option<String>,
10 }
11
12 impl RestEnvironment {
13 pub fn new(env_type: RpcEnvironmentType) -> Self {
14 Self {
15 result_attributes: HashMap::new(),
16 user: None,
17 env_type,
18 }
19 }
20 }
21
22 impl RpcEnvironment for RestEnvironment {
23
24 fn set_result_attrib(&mut self, name: &str, value: Value) {
25 self.result_attributes.insert(name.into(), value);
26 }
27
28 fn get_result_attrib(&self, name: &str) -> Option<&Value> {
29 self.result_attributes.get(name)
30 }
31
32 fn env_type(&self) -> RpcEnvironmentType {
33 self.env_type
34 }
35
36 fn set_user(&mut self, user: Option<String>) {
37 self.user = user;
38 }
39
40 fn get_user(&self) -> Option<String> {
41 self.user.clone()
42 }
43 }