]> git.proxmox.com Git - proxmox-backup.git/blob - src/server/environment.rs
clippy: remove unnecessary clones
[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 auth_id: Option<String>,
10 client_ip: Option<std::net::SocketAddr>,
11 }
12
13 impl RestEnvironment {
14 pub fn new(env_type: RpcEnvironmentType) -> Self {
15 Self {
16 result_attributes: json!({}),
17 auth_id: None,
18 client_ip: None,
19 env_type,
20 }
21 }
22 }
23
24 impl RpcEnvironment for RestEnvironment {
25
26 fn result_attrib_mut (&mut self) -> &mut Value {
27 &mut self.result_attributes
28 }
29
30 fn result_attrib(&self) -> &Value {
31 &self.result_attributes
32 }
33
34 fn env_type(&self) -> RpcEnvironmentType {
35 self.env_type
36 }
37
38 fn set_auth_id(&mut self, auth_id: Option<String>) {
39 self.auth_id = auth_id;
40 }
41
42 fn get_auth_id(&self) -> Option<String> {
43 self.auth_id.clone()
44 }
45
46 fn set_client_ip(&mut self, client_ip: Option<std::net::SocketAddr>) {
47 self.client_ip = client_ip;
48 }
49
50 fn get_client_ip(&self) -> Option<std::net::SocketAddr> {
51 self.client_ip
52 }
53 }