1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
use std;
use std::error::Error;
use std::collections::HashMap;
#[derive(RustcEncodable, RustcDecodable)]
#[allow(non_snake_case)]
pub struct Container {
pub Id: String,
pub Image: String,
pub Status: String,
pub Command: String,
pub Created: u64,
pub Names: Vec<String>,
pub Ports: Vec<Port>,
pub SizeRw: Option<u64>,
pub SizeRootFs: u64,
pub Labels: Option<HashMap<String, String>>,
pub HostConfig: HostConfig
}
#[derive(RustcEncodable, RustcDecodable)]
#[allow(non_snake_case)]
pub struct Port {
pub IP: Option<String>,
pub PrivatePort: u64,
pub PublicPort: Option<u64>,
pub Type: String
}
#[derive(RustcEncodable, RustcDecodable)]
#[allow(non_snake_case)]
pub struct HostConfig {
pub NetworkMode: String
}
#[derive(RustcEncodable, RustcDecodable)]
#[allow(non_snake_case)]
pub struct ContainerInfo {
pub AppArmorProfile: String,
pub Args: Vec<String>,
pub Created: String,
pub Driver: String,
pub ExecDriver: String,
pub HostnamePath: String,
pub HostsPath: String,
pub LogPath: String,
pub Id: String,
pub Image: String,
pub MountLabel: String,
pub Name: String,
pub Path: String,
pub ProcessLabel: String,
pub ResolvConfPath: String,
pub RestartCount: u64,
pub Volumes: HashMap<String, String>,
pub VolumesRW: HashMap<String, bool>
}
impl Clone for Container {
fn clone(&self) -> Self {
let container = Container {
Id: self.Id.clone(),
Image: self.Image.clone(),
Status: self.Status.clone(),
Command: self.Command.clone(),
Created: self.Created.clone(),
Names: self.Names.clone(),
Ports: self.Ports.clone(),
SizeRw: self.SizeRw,
SizeRootFs: self.SizeRootFs,
Labels: self.Labels.clone(),
HostConfig: self.HostConfig.clone()
};
return container;
}
}
impl std::fmt::Display for Container {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
write!(f, "{}", self.Id)
}
}
impl std::clone::Clone for Port {
fn clone(&self) -> Self {
let port = Port {
IP: self.IP.clone(),
PrivatePort: self.PrivatePort.clone(),
PublicPort: self.PublicPort.clone(),
Type: self.Type.clone()
};
return port;
}
}
impl Clone for HostConfig {
fn clone(&self) -> Self {
let host_config = HostConfig {
NetworkMode: self.NetworkMode.clone()
};
return host_config;
}
}
impl Clone for ContainerInfo {
fn clone(&self) -> Self {
let container_info = ContainerInfo {
AppArmorProfile: self.AppArmorProfile.clone(),
Args: self.Args.clone(),
Created: self.Created.clone(),
Driver: self.Driver.clone(),
ExecDriver: self.ExecDriver.clone(),
HostnamePath: self.HostnamePath.clone(),
HostsPath: self.HostsPath.clone(),
LogPath: self.LogPath.clone(),
Id: self.Id.clone(),
Image: self.Image.clone(),
MountLabel: self.MountLabel.clone(),
Name: self.Name.clone(),
Path: self.Path.clone(),
ProcessLabel: self.ProcessLabel.clone(),
ResolvConfPath: self.ResolvConfPath.clone(),
RestartCount: self.RestartCount,
Volumes: self.Volumes.clone(),
VolumesRW: self.VolumesRW.clone()
};
return container_info;
}
}
impl std::fmt::Display for ContainerInfo {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
write!(f, "{}", self.Id)
}
}