docker-client-async 0.1.0

A modern async/await Docker client written in Rust.
Documentation
/*
 * Copyright 2020 Damian Peckett <damian@pecke.tt>.
 * Copyright 2013-2018 Docker, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

use derive_builder::Builder;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

/// PortMap is a collection of PortBinding indexed by Port.
pub type PortMap = HashMap<String, Vec<PortBinding>>;

/// PortSet is a collection of structs indexed by Port.
pub type PortSet = HashMap<String, HashMap<String, Value>>;

/// Port An open port on a container.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Builder)]
#[builder(default, setter(into))]
pub struct Port {
    /// Host IP address that the container's port is mapped to.
    #[serde(rename = "IP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ip: Option<String>,
    /// Port on the container.
    #[serde(rename = "PrivatePort")]
    pub private_port: u16,
    /// Port exposed on the host.
    #[serde(rename = "PublicPort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub public_port: Option<u16>,
    /// Port type.
    #[serde(rename = "Type")]
    pub port_type: String,
}

/// PortBinding represents a binding between a Host IP address and a Host Port.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Builder)]
#[builder(default, setter(into))]
pub struct PortBinding {
    /// HostIP is the host IP Address.
    #[serde(rename = "HostIp")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host_ip: Option<String>,
    /// HostPort is the host port number.
    #[serde(rename = "HostPort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host_port: Option<String>,
}