//! Interfaces for building various structures
// Std lib
use std::cmp::Eq;
use std::collections::{BTreeMap, HashMap};
use std::hash::Hash;
use std::iter::IntoIterator;
use std::iter::Peekable;
// Third party
use serde::Serialize;
use serde_json::{self, map::Map, Value};
use url::form_urlencoded;
// Ours
use errors::Error;
use Result;
#[derive(Default)]
pub struct PullOptions {
params: HashMap<&'static str, String>,
}
impl PullOptions {
/// return a new instance of a builder for options
pub fn builder() -> PullOptionsBuilder {
PullOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
pub fn serialize(&self) -> Option<String> {
if self.params.is_empty() {
None
} else {
Some(
form_urlencoded::Serializer::new(String::new())
.extend_pairs(&self.params)
.finish(),
)
}
}
}
#[derive(Default)]
pub struct PullOptionsBuilder {
params: HashMap<&'static str, String>,
}
impl PullOptionsBuilder {
pub fn image<I>(
&mut self,
img: I,
) -> &mut Self
where
I: Into<String>,
{
self.params.insert("fromImage", img.into());
self
}
pub fn src<S>(
&mut self,
s: S,
) -> &mut Self
where
S: Into<String