use std;
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Debug)]
#[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(Serialize, Deserialize, Debug)]
#[allow(non_snake_case)]
pub struct Port {
pub IP: Option<String>,
pub PrivatePort: u64,
pub PublicPort: Option<u64>,
pub Type: String
}
#[derive(Serialize, Deserialize, Debug)]
#[allow(non_snake_case)]
pub struct HostConfig {
pub NetworkMode: String
}
#[derive(Serialize, Deserialize, Debug)]
#[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)
}
}