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