1use std;
2use std::collections::HashMap;
3
4#[derive(Serialize, Deserialize, Debug)]
5#[allow(non_snake_case)]
6pub struct Container {
8 pub Id: String,
9 pub Image: String,
10 pub Status: String,
11 pub Command: String,
12 pub Created: u64,
13 pub Names: Vec<String>,
14 pub Ports: Vec<Port>,
15 pub SizeRw: Option<u64>, pub SizeRootFs: u64,
17 pub Labels: Option<HashMap<String, String>>,
18 pub HostConfig: HostConfig,
19}
20
21#[derive(Serialize, Deserialize, Debug)]
22#[allow(non_snake_case)]
23pub struct Port {
24 pub IP: Option<String>,
25 pub PrivatePort: u64,
26 pub PublicPort: Option<u64>,
27 pub Type: String,
28}
29
30#[derive(Serialize, Deserialize, Debug)]
31#[allow(non_snake_case)]
32pub struct HostConfig {
33 pub NetworkMode: String,
34}
35
36#[derive(Serialize, Deserialize, Debug)]
37#[allow(non_snake_case)]
38pub struct ContainerInfo {
39 pub AppArmorProfile: String,
40 pub Args: Vec<String>,
41 pub Created: String,
43 pub Driver: String,
44 pub ExecDriver: String,
45 pub HostnamePath: String,
48 pub HostsPath: String,
49 pub LogPath: String,
50 pub Id: String,
51 pub Image: String,
52 pub MountLabel: String,
53 pub Name: String,
54 pub Path: String,
56 pub ProcessLabel: String,
57 pub ResolvConfPath: String,
58 pub RestartCount: u64,
59 pub Volumes: HashMap<String, String>,
61 pub VolumesRW: HashMap<String, bool>,
62}
63
64impl Clone for Container {
65 fn clone(&self) -> Self {
66 let container = Container {
67 Id: self.Id.clone(),
68 Image: self.Image.clone(),
69 Status: self.Status.clone(),
70 Command: self.Command.clone(),
71 Created: self.Created.clone(),
72 Names: self.Names.clone(),
73 Ports: self.Ports.clone(),
74 SizeRw: self.SizeRw,
75 SizeRootFs: self.SizeRootFs,
76 Labels: self.Labels.clone(),
77 HostConfig: self.HostConfig.clone(),
78 };
79
80 return container;
81 }
82}
83
84impl std::fmt::Display for Container {
85 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
86 write!(f, "{}", self.Id)
87 }
88}
89
90impl std::clone::Clone for Port {
91 fn clone(&self) -> Self {
92 let port = Port {
93 IP: self.IP.clone(),
94 PrivatePort: self.PrivatePort.clone(),
95 PublicPort: self.PublicPort.clone(),
96 Type: self.Type.clone(),
97 };
98 return port;
99 }
100}
101
102impl Clone for HostConfig {
103 fn clone(&self) -> Self {
104 let host_config = HostConfig {
105 NetworkMode: self.NetworkMode.clone(),
106 };
107 return host_config;
108 }
109}
110
111impl Clone for ContainerInfo {
112 fn clone(&self) -> Self {
113 let container_info = ContainerInfo {
114 AppArmorProfile: self.AppArmorProfile.clone(),
115 Args: self.Args.clone(),
116 Created: self.Created.clone(),
118 Driver: self.Driver.clone(),
119 ExecDriver: self.ExecDriver.clone(),
120 HostnamePath: self.HostnamePath.clone(),
123 HostsPath: self.HostsPath.clone(),
124 LogPath: self.LogPath.clone(),
125 Id: self.Id.clone(),
126 Image: self.Image.clone(),
127 MountLabel: self.MountLabel.clone(),
128 Name: self.Name.clone(),
129 Path: self.Path.clone(),
131 ProcessLabel: self.ProcessLabel.clone(),
132 ResolvConfPath: self.ResolvConfPath.clone(),
133 RestartCount: self.RestartCount,
134 Volumes: self.Volumes.clone(),
136 VolumesRW: self.VolumesRW.clone(),
137 };
138 return container_info;
139 }
140}
141
142impl std::fmt::Display for ContainerInfo {
143 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
144 write!(f, "{}", self.Id)
145 }
146}
147
148#[derive(Serialize, Deserialize, Debug)]
149#[allow(non_snake_case)]
150pub struct PortBinding {
151 pub HostIp: Option<String>,
152 pub HostPort: String,
153}
154
155impl Clone for PortBinding {
156 fn clone(&self) -> Self {
157 PortBinding {
158 HostIp: self.HostIp.clone(),
159 HostPort: self.HostPort.clone(),
160 }
161 }
162}
163
164impl std::fmt::Display for PortBinding {
165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
166 write!(f, "{}", self.HostPort)
167 }
168}
169
170#[derive(Serialize, Deserialize, Debug)]
171#[allow(non_snake_case)]
172pub struct HostConfigCreate {
173 pub NetworkMode: Option<String>,
174 pub PublishAllPorts: Option<bool>,
175 pub PortBindings: Option<HashMap<String, Vec<PortBinding>>>,
176}
177
178impl Clone for HostConfigCreate {
179 fn clone(&self) -> Self {
180 HostConfigCreate {
181 NetworkMode: self.NetworkMode.clone(),
182 PublishAllPorts: self.PublishAllPorts.clone(),
183 PortBindings: self.PortBindings.clone(),
184 }
185 }
186}
187
188impl std::fmt::Display for HostConfigCreate {
189 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
190 write!(f, "{:#?}", self.NetworkMode)
191 }
192}
193
194#[derive(Serialize, Deserialize, Debug)]
195#[allow(non_snake_case)]
196pub struct ContainerCreate {
197 pub Image: String,
198 pub Labels: Option<HashMap<String, String>>,
199 pub ExposedPorts: Option<HashMap<String, HashMap<i32, i32>>>,
200 pub HostConfig: Option<HostConfigCreate>,
201}
202
203impl Clone for ContainerCreate {
204 fn clone(&self) -> Self {
205 ContainerCreate {
206 Image: self.Image.clone(),
207 Labels: self.Labels.clone(),
208 ExposedPorts: self.ExposedPorts.clone(),
209 HostConfig: self.HostConfig.clone(),
210 }
211 }
212}
213
214impl std::fmt::Display for ContainerCreate {
215 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
216 write!(f, "{}", self.Image)
217 }
218}