]> git.proxmox.com Git - proxmox-backup.git/blob - src/server/environment.rs
depend on proxmox 0.1.31 - use Value to store result metadata
[proxmox-backup.git] / src / server / environment.rs
1 use serde_json::{json, Value};
2
3 use proxmox::api::{RpcEnvironment, RpcEnvironmentType};
4
5 /// Encapsulates information about the runtime environment
6 pub struct RestEnvironment {
7 env_type: RpcEnvironmentType,
8 result_attributes: Value,
9 user: Option<String>,
10 }
11
12 impl RestEnvironment {
13 pub fn new(env_type: RpcEnvironmentType) -> Self {
14 Self {
15 result_attributes: json!({}),
16 user: None,
17 env_type,
18 }
19 }
20 }
21
22 impl RpcEnvironment for RestEnvironment {
23
24 fn result_attrib_mut (&mut self) -> &mut Value {
25 &mut self.result_attributes
26 }
27
28 fn result_attrib(&self) -> &Value {
29 &self.result_attributes
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 }