summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsoftprops <d.tangren@gmail.com>2017-09-09 14:16:55 -0400
committersoftprops <d.tangren@gmail.com>2017-09-09 14:16:55 -0400
commit022388eb97c95e8383cd947c31f5f0dbc3798fbf (patch)
treef0a0ce2e206d5a2d70033b8f40f54493d5e33a42
parent51751f08f8f3e840ea349518536d9316888071d6 (diff)
code style enforcement
-rw-r--r--examples/export.rs2
-rw-r--r--examples/networkcreate.rs2
-rw-r--r--rustfmt.toml10
-rw-r--r--src/builder.rs118
-rw-r--r--src/errors.rs6
-rw-r--r--src/lib.rs111
-rw-r--r--src/tarball.rs3
-rw-r--r--src/transport.rs37
-rw-r--r--src/tty.rs17
9 files changed, 221 insertions, 85 deletions
diff --git a/examples/export.rs b/examples/export.rs
index d37ebad..b12e2f8 100644
--- a/examples/export.rs
+++ b/examples/export.rs
@@ -2,8 +2,8 @@ extern crate shiplift;
use shiplift::Docker;
use std::env;
-use std::io::copy;
use std::fs::OpenOptions;
+use std::io::copy;
fn main() {
let docker = Docker::new();
diff --git a/examples/networkcreate.rs b/examples/networkcreate.rs
index fb664d6..8afce82 100644
--- a/examples/networkcreate.rs
+++ b/examples/networkcreate.rs
@@ -1,6 +1,6 @@
extern crate shiplift;
-use shiplift::{NetworkCreateOptions, Docker};
+use shiplift::{Docker, NetworkCreateOptions};
use std::env;
fn main() {
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 0000000..d83987d
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1,10 @@
+# keep imports tidy
+reorder_imported_names = true
+reorder_imports = true
+reorder_imports_in_group = true
+# there is no try!
+use_try_shorthand = true
+# don't create rustfmt artifacts
+write_mode = "Replace"
+# reduce wide load
+max_width = 80 \ No newline at end of file
diff --git a/src/builder.rs b/src/builder.rs
index 042f8da..acad3f8 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -1,12 +1,12 @@
//! Interfaces for building various structures
-use rustc_serialize::json::{self, Json, ToJson};
use self::super::Result;
+use rustc_serialize::json::{self, Json, ToJson};
use std::cmp::Eq;
use std::collections::{BTreeMap, HashMap};
-use std::iter::Peekable;
use std::hash::Hash;
use std::iter::IntoIterator;
+use std::iter::Peekable;
use url::form_urlencoded;
#[derive(Default)]
@@ -222,14 +222,21 @@ impl ContainerListOptionsBuilder {
ContainerListOptionsBuilder { ..Default::default() }
}
- pub fn filter(&mut self, filters: Vec<ContainerFilter>) -> &mut ContainerListOptionsBuilder {
+ pub fn filter(
+ &mut self,
+ filters: Vec<ContainerFilter>,
+ ) -> &mut ContainerListOptionsBuilder {
let mut param = HashMap::new();
for f in filters {
match f {
- ContainerFilter::ExitCode(c) => param.insert("exit", vec![c.to_string()]),
+ ContainerFilter::ExitCode(c) => {
+ param.insert("exit", vec![c.to_string()])
+ }
ContainerFilter::Status(s) => param.insert("status", vec![s]),
ContainerFilter::LabelName(n) => param.insert("label", vec![n]),
- ContainerFilter::Label(n, v) => param.insert("label", vec![format!("{}={}", n, v)]),
+ ContainerFilter::Label(n, v) => {
+ param.insert("label", vec![format!("{}={}", n, v)])
+ }
};
}
@@ -278,7 +285,10 @@ impl ToJson for ContainerOptions {
// The HostConfig element gets initialized to an empty object,
// for backward compatibility.
- body_members.insert("HostConfig".to_string(), Json::Object(BTreeMap::new()));
+ body_members.insert(
+ "HostConfig".to_string(),
+ Json::Object(BTreeMap::new()),
+ );
let mut body = Json::Object(body_members);
@@ -292,8 +302,11 @@ impl ToJson for ContainerOptions {
/// Function to insert a JSON value into a tree where the desired
/// location of the value is given as a path of JSON keys.
-fn insert<'a, I, V>(key_path: &mut Peekable<I>, value: &V, parent_node: &mut Json)
-where
+fn insert<'a, I, V>(
+ key_path: &mut Peekable<I>,
+ value: &V,
+ parent_node: &mut Json,
+) where
V: ToJson,
I: Iterator<Item = &'a str>,
{
@@ -326,8 +339,11 @@ impl ContainerOptions {
Ok(json::encode(&self.to_json())?)
}
- pub fn parse_from<'a, K, V>(&self, params: &'a HashMap<K, V>, body: &mut Json)
- where
+ pub fn parse_from<'a, K, V>(
+ &self,
+ params: &'a HashMap<K, V>,
+ body: &mut Json,
+ ) where
&'a HashMap<K, V>: IntoIterator,
K: ToString + Eq + Hash,
V: ToJson,
@@ -367,7 +383,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn volumes(&mut self, volumes: Vec<&str>) -> &mut ContainerOptionsBuilder {
+ pub fn volumes(
+ &mut self,
+ volumes: Vec<&str>,
+ ) -> &mut ContainerOptionsBuilder {
for v in volumes {
self.params_list
.entry("HostConfig.Binds")
@@ -387,7 +406,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn extra_hosts(&mut self, hosts: Vec<&str>) -> &mut ContainerOptionsBuilder {
+ pub fn extra_hosts(
+ &mut self,
+ hosts: Vec<&str>,
+ ) -> &mut ContainerOptionsBuilder {
for host in hosts {
self.params_list
.entry("HostConfig.ExtraHosts")
@@ -398,7 +420,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn volumes_from(&mut self, volumes: Vec<&str>) -> &mut ContainerOptionsBuilder {
+ pub fn volumes_from(
+ &mut self,
+ volumes: Vec<&str>,
+ ) -> &mut ContainerOptionsBuilder {
for volume in volumes {
self.params_list
.entry("HostConfig.VolumesFrom")
@@ -408,7 +433,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn network_mode(&mut self, network: &str) -> &mut ContainerOptionsBuilder {
+ pub fn network_mode(
+ &mut self,
+ network: &str,
+ ) -> &mut ContainerOptionsBuilder {
if !network.is_empty() {
self.params.insert(
"HostConfig.NetworkMode",
@@ -436,7 +464,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn entrypoint(&mut self, entrypoint: &str) -> &mut ContainerOptionsBuilder {
+ pub fn entrypoint(
+ &mut self,
+ entrypoint: &str,
+ ) -> &mut ContainerOptionsBuilder {
if !entrypoint.is_empty() {
self.params.insert(
"Entrypoint",
@@ -446,7 +477,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn capabilities(&mut self, capabilities: Vec<&str>) -> &mut ContainerOptionsBuilder {
+ pub fn capabilities(
+ &mut self,
+ capabilities: Vec<&str>,
+ ) -> &mut ContainerOptionsBuilder {
for c in capabilities {
self.params_list
.entry("HostConfig.CapAdd")
@@ -469,7 +503,10 @@ impl ContainerOptionsBuilder {
self
}
- pub fn log_driver(&mut self, log_driver: &str) -> &mut ContainerOptionsBuilder {
+ pub fn log_driver(
+ &mut self,
+ log_driver: &str,
+ ) -> &mut ContainerOptionsBuilder {
if !log_driver.is_empty() {
self.params.insert(
"HostConfig.LogConfig.Type",
@@ -571,13 +608,19 @@ impl ExecContainerOptionsBuilder {
}
/// Attach to stdout of the exec command
- pub fn attach_stdout(&mut self, stdout: bool) -> &mut ExecContainerOptionsBuilder {
+ pub fn attach_stdout(
+ &mut self,
+ stdout: bool,
+ ) -> &mut ExecContainerOptionsBuilder {
self.params_bool.insert("AttachStdout", stdout);
self
}
/// Attach to stderr of the exec command
- pub fn attach_stderr(&mut self, stderr: bool) -> &mut ExecContainerOptionsBuilder {
+ pub fn attach_stderr(
+ &mut self,
+ stderr: bool,
+ ) -> &mut ExecContainerOptionsBuilder {
self.params_bool.insert("AttachStderr", stderr);
self
}
@@ -665,7 +708,10 @@ impl EventsOptionsBuilder {
self
}
- pub fn filter(&mut self, filters: Vec<EventFilter>) -> &mut EventsOptionsBuilder {
+ pub fn filter(
+ &mut self,
+ filters: Vec<EventFilter>,
+ ) -> &mut EventsOptionsBuilder {
let mut param = HashMap::new();
for f in filters {
match f {
@@ -677,7 +723,10 @@ impl EventsOptionsBuilder {
EventFilter::Network(n) => param.insert("network", vec![n]),
EventFilter::Daemon(n) => param.insert("daemon", vec![n]),
EventFilter::Type(n) => {
- param.insert("type", vec![event_filter_type_to_string(n).to_string()])
+ param.insert(
+ "type",
+ vec![event_filter_type_to_string(n).to_string()],
+ )
}
};
@@ -809,13 +858,20 @@ impl ImageListOptionsBuilder {
self
}
- pub fn filter(&mut self, filters: Vec<ImageFilter>) -> &mut ImageListOptionsBuilder {
+ pub fn filter(
+ &mut self,
+ filters: Vec<ImageFilter>,
+ ) -> &mut ImageListOptionsBuilder {
let mut param = HashMap::new();
for f in filters {
match f {
- ImageFilter::Dangling => param.insert("dangling", vec![true.to_string()]),
+ ImageFilter::Dangling => {
+ param.insert("dangling", vec![true.to_string()])
+ }
ImageFilter::LabelName(n) => param.insert("label", vec![n]),
- ImageFilter::Label(n, v) => param.insert("label", vec![format!("{}={}", n, v)]),
+ ImageFilter::Label(n, v) => {
+ param.insert("label", vec![format!("{}={}", n, v)])
+ }
};
}
@@ -925,8 +981,11 @@ impl NetworkCreateOptions {
Ok(json::encode(&self.to_json())?)
}
- pub fn parse_from<'a, K, V>(&self, params: &'a HashMap<K, V>, body: &mut BTreeMap<String, Json>)
- where
+ pub fn parse_from<'a, K, V>(
+ &self,
+ params: &'a HashMap<K, V>,
+ body: &mut BTreeMap<String, Json>,
+ ) where
&'a HashMap<K, V>: IntoIterator,
K: ToString + Eq + Hash,
V: ToJson,
@@ -1010,8 +1069,11 @@ impl ContainerConnectionOptions {
Ok(json::encode(&self.to_json())?)
}
- pub fn parse_from<'a, K, V>(&self, params: &'a HashMap<K, V>, body: &mut BTreeMap<String, Json>)
- where
+ pub fn parse_from<'a, K, V>(
+ &self,
+ params: &'a HashMap<K, V>,
+ body: &mut BTreeMap<String, Json>,
+ ) where
&'a HashMap<K, V>: IntoIterator,
K: ToString + Eq + Hash,
V: ToJson,
diff --git a/src/errors.rs b/src/errors.rs
index bb69ea5..856a010 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -1,11 +1,11 @@
//! Representations of various client errors
-use std::error::Error as ErrorTrait;
-use std::io::Error as IoError;
-use std::fmt;
use hyper::Error as HttpError;
use hyper::status::StatusCode;
use rustc_serialize::json::{DecoderError, EncoderError, ParserError};
+use std::error::Error as ErrorTrait;
+use std::fmt;
+use std::io::Error as IoError;
#[derive(Debug)]
pub enum Error {
diff --git a/src/lib.rs b/src/lib.rs
index 6cef1da..b6a90a2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -34,25 +34,26 @@ pub mod tty;
mod tarball;
+pub use builder::{BuildOptions, ContainerConnectionOptions, ContainerFilter,
+ ContainerListOptions, ContainerOptions, EventsOptions,
+ ExecContainerOptions, ImageFilter, ImageListOptions,
+ LogsOptions, NetworkCreateOptions, NetworkListOptions,
+ PullOptions, RmContainerOptions};
pub use errors::Error;
-pub use builder::{BuildOptions, ContainerOptions, ContainerListOptions, ContainerFilter,
- EventsOptions, ImageFilter, ImageListOptions, LogsOptions, PullOptions,
- RmContainerOptions, ExecContainerOptions, NetworkListOptions,
- NetworkCreateOptions, ContainerConnectionOptions};
use hyper::{Client, Url};
+use hyper::client::Body;
use hyper::header::ContentType;
-use hyper::net::HttpsConnector;
use hyper::method::Method;
+use hyper::net::HttpsConnector;
use hyper_openssl::OpensslClient;
use hyperlocal::UnixSocketConnector;
+use openssl::ssl::{SslConnectorBuilder, SslMethod};
use openssl::x509::X509_FILETYPE_PEM;
-use openssl::ssl::{SslMethod, SslConnectorBuilder};
+use rep::{Change, Container as ContainerRep, ContainerCreateInfo,
+ ContainerDetails, Event, Exit, History, ImageDetails, Info,
+ SearchResult, Stats, Status, Top, Version};
+use rep::{NetworkCreateInfo, NetworkDetails as NetworkInfo};
use rep::Image as ImageRep;
-use rep::{NetworkDetails as NetworkInfo, NetworkCreateInfo};
-use rep::{Change, ContainerCreateInfo, ContainerDetails, Container as ContainerRep,
- Event, Exit, History, ImageDetails, Info, SearchResult, Stats, Status, Top,
- Version};
-use tty::Tty;
use rustc_serialize::json::{self, Json};
use std::borrow::Cow;
use std::env::{self, VarError};
@@ -60,8 +61,8 @@ use std::io::Read;
use std::iter::IntoIterator;
use std::path::Path;
use std::time::Duration;
-use transport::{tar, Transport};
-use hyper::client::Body;
+use transport::{Transport, tar};
+use tty::Tty;
use url::form_urlencoded;
/// Represents the result of all docker operations
@@ -116,14 +117,18 @@ impl<'a, 'b> Image<'a, 'b> {
.map(|sha| {
Status::Untagged(
sha.as_string()
- .expect("expected Untagged to be a string")
+ .expect(
+ "expected Untagged to be a string",
+ )
.to_owned(),
)
})
.or(obj.get("Deleted").map(|sha| {
Status::Deleted(
sha.as_string()
- .expect("expected Deleted to be a string")
+ .expect(
+ "expected Deleted to be a string",
+ )
.to_owned(),
)
}))
@@ -155,7 +160,10 @@ impl<'a> Images<'a> {
}
/// Builds a new image build by reading a Dockerfile in a target directory
- pub fn build(&self, opts: &BuildOptions) -> Result<Box<Iterator<Item = Json>>> {
+ pub fn build(
+ &self,
+ opts: &BuildOptions,
+ ) -> Result<Box<Iterator<Item = Json>>> {
let mut path = vec!["/build".to_owned()];
if let Some(query) = opts.serialize() {
path.push(query)
@@ -198,7 +206,10 @@ impl<'a> Images<'a> {
}
/// Pull and create a new docker images from an existing image
- pub fn pull(&self, opts: &PullOptions) -> Result<Box<Iterator<Item = Json>>> {
+ pub fn pull(
+ &self,
+ opts: &PullOptions,
+ ) -> Result<Box<Iterator<Item = Json>>> {
let mut path = vec!["/images/create".to_owned()];
if let Some(query) = opts.serialize() {
path.push(query);
@@ -324,7 +335,9 @@ impl<'a, 'b> Container<'a, 'b> {
pub fn stop(&self, wait: Option<Duration>) -> Result<()> {
let mut path = vec![format!("/containers/{}/stop", self.id)];
if let Some(w) = wait {
- let encoded = form_urlencoded::serialize(vec![("t", w.as_secs().to_string())]);
+ let encoded = form_urlencoded::serialize(
+ vec![("t", w.as_secs().to_string())],
+ );
path.push(encoded)
}
self.docker
@@ -336,7 +349,9 @@ impl<'a, 'b> Container<'a, 'b> {
pub fn restart(&self, wait: Option<Duration>) -> Result<()> {
let mut path = vec![format!("/containers/{}/restart", self.id)];
if let Some(w) = wait {
- let encoded = form_urlencoded::serialize(vec![("t", w.as_secs().to_string())]);
+ let encoded = form_urlencoded::serialize(
+ vec![("t", w.as_secs().to_string())],
+ );
path.push(encoded)
}
self.docker
@@ -348,7 +363,8 @@ impl<'a, 'b> Container<'a, 'b> {
pub fn kill(&self, signal: Option<&str>) -> Result<()> {
let mut path = vec![format!("/containers/{}/kill", self.id)];
if let Some(sig) = signal {
- let encoded = form_urlencoded::serialize(vec![("signal", sig.to_owned())]);
+ let encoded =
+ form_urlencoded::serialize(vec![("signal", sig.to_owned())]);
path.push(encoded)
}
self.docker
@@ -461,7 +477,10 @@ impl<'a> Containers<'a> {
}
/// Lists the container instances on the docker host
- pub fn list(&self, opts: &ContainerListOptions) -> Result<Vec<ContainerRep>> {
+ pub fn list(
+ &self,
+ opts: &ContainerListOptions,
+ ) -> Result<Vec<ContainerRep>> {
let mut path = vec!["/containers/json".to_owned()];
if let Some(query) = opts.serialize() {
path.push(query)
@@ -476,7 +495,10 @@ impl<'a> Containers<'a> {
}
/// Returns a builder interface for creating a new container instance
- pub fn create(&'a self, opts: &ContainerOptions) -> Result<ContainerCreateInfo> {
+ pub fn create(
+ &'a self,
+ opts: &ContainerOptions,
+ ) -> Result<ContainerCreateInfo> {
let data = opts.serialize()?;
let mut bytes = data.as_bytes();
let mut path = vec!["/containers/create".to_owned()];
@@ -519,7 +541,10 @@ impl<'a> Networks<'a> {
Network::new(self.docker, id)
}
- pub fn create(&'a self, opts: &NetworkCreateOptions) -> Result<NetworkCreateInfo> {
+ pub fn create(
+ &'a self,
+ opts: &NetworkCreateOptions,
+ ) -> Result<NetworkCreateInfo> {
let data = opts.serialize()?;
let mut bytes = data.as_bytes();
let path = vec!["/networks/create".to_owned()];
@@ -578,7 +603,11 @@ impl<'a, 'b> Network<'a, 'b> {
self.do_connection("disconnect", opts)
}
- fn do_connection(&self, segment: &str, opts: &ContainerConnectionOptions) -> Result<()> {
+ fn do_connection(
+ &self,
+ segment: &str,
+ opts: &ContainerConnectionOptions,
+ ) -> Result<()> {
let data = opts.serialize()?;
let mut bytes = data.as_bytes();
@@ -618,24 +647,37 @@ impl Docker {
}
}
_ => {
- let client = if let Some(ref certs) = env::var("DOCKER_CERT_PATH").ok() {
+ let client = if let Some(ref certs) = env::var(
+ "DOCKER_CERT_PATH",
+ ).ok()
+ {
// fixme: don't unwrap before you know what's in the box
// https://github.com/hyperium/hyper/blob/master/src/net.rs#L427-L428
- let mut connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap();
+ let mut connector =
+ SslConnectorBuilder::new(SslMethod::tls()).unwrap();
connector.builder_mut().set_cipher_list("DEFAULT").unwrap();
let cert = &format!("{}/cert.pem", certs);
let key = &format!("{}/key.pem", certs);
connector
.builder_mut()
- .set_certificate_file(&Path::new(cert), X509_FILETYPE_PEM)
+ .set_certificate_file(
+ &Path::new(cert),
+ X509_FILETYPE_PEM,
+ )
.unwrap();
connector
.builder_mut()
- .set_private_key_file(&Path::new(key), X509_FILETYPE_PEM)
+ .set_private_key_file(
+ &Path::new(key),
+ X509_FILETYPE_PEM,
+ )
.unwrap();
if let Some(_) = env::var("DOCKER_TLS_VERIFY").ok() {
let ca = &format!("{}/ca.pem", certs);
- connector.builder_mut().set_ca_file(&Path::new(ca)).unwrap();
+ connector
+ .builder_mut()
+ .set_ca_file(&Path::new(ca))
+ .unwrap();
}
let ssl = OpensslClient::from(connector.build());
Client::with_connector(HttpsConnector::new(ssl))
@@ -689,7 +731,10 @@ impl Docker {
}
/// Returns an interator over streamed docker events
- pub fn events(&self, opts: &EventsOptions) -> Result<Box<Iterator<Item = Event>>> {
+ pub fn events(
+ &self,
+ opts: &EventsOptions,
+ ) -> Result<Box<Iterator<Item = Event>>> {
let mut path = vec!["/events".to_owned()];
if let Some(query) = opts.serialize() {
path.push(query);
@@ -712,7 +757,11 @@ impl Docker {
)
}
- fn post<'a, B>(&'a self, endpoint: &str, body: Option<(B, ContentType)>) -> Result<String>
+ fn post<'a, B>(
+ &'a self,
+ endpoint: &str,
+ body: Option<(B, ContentType)>,
+ ) -> Result<String>
where
B: Into<Body<'a>>,
{
diff --git a/src/tarball.rs b/src/tarball.rs
index 21b5113..50dd97d 100644
--- a/src/tarball.rs
+++ b/src/tarball.rs
@@ -1,9 +1,8 @@
-
use flate2::Compression;
use flate2::write::GzEncoder;
use std::fs::{self, File};
-use std::path::{Path, MAIN_SEPARATOR};
use std::io::{self, Write};
+use std::path::{MAIN_SEPARATOR, Path};
use tar::Archive;
// todo: this is pretty involved. (re)factor this into its own crate
diff --git a/src/transport.rs b/src/transport.rs
index 489eb97..c7c5d1e 100644
--- a/src/transport.rs
+++ b/src/transport.rs
@@ -2,20 +2,20 @@
extern crate hyper;
+use self::hyper::buffer::BufReader;
+use self::hyper::header::ContentType;
+use self::hyper::status::StatusCode;
+use self::super::{Error, Result};
use hyper::Client;
use hyper::client::Body;
use hyper::client::response::Response;
use hyper::header;
-use hyper::mime;
-use self::super::{Error, Result};
-use self::hyper::buffer::BufReader;
-use self::hyper::header::ContentType;
-use self::hyper::status::StatusCode;
use hyper::method::Method;
-use std::fmt;
-use std::io::Read;
+use hyper::mime;
use hyperlocal::DomainUrl;
use rustc_serialize::json;
+use std::fmt;
+use std::io::Read;
pub fn tar() -> ContentType {
ContentType(mime::Mime(
@@ -97,30 +97,43 @@ impl Transport {
StatusCode::Ok |
StatusCode::Created |
StatusCode::SwitchingProtocols => Ok(Box::new(res)),
- StatusCode::NoContent => Ok(Box::new(BufReader::new("".as_bytes()))),
+ StatusCode::NoContent => Ok(
+ Box::new(BufReader::new("".as_bytes())),
+ ),
// todo: constantize these
StatusCode::BadRequest => {
Err(Error::Fault {
code: res.status,
- message: get_error_message(&mut res).unwrap_or("bad parameter".to_owned()),
+ message: get_error_message(&mut res).unwrap_or(
+ "bad parameter"
+ .to_owned(),
+ ),
})
}
StatusCode::NotFound => {
Err(Error::Fault {
code: res.status,
- message: get_error_message(&mut res).unwrap_or("not found".to_owned()),
+ message: get_error_message(&mut res).unwrap_or(
+ "not found".to_owned(),
+ ),
})
}
StatusCode::NotAcceptable => {
Err(Error::Fault {
code: res.status,
- message: get_error_message(&mut res).unwrap_or("not acceptable".to_owned()),
+ message: get_error_message(&mut res).unwrap_or(
+ "not acceptable"
+ .to_owned(),
+ ),
})
}
StatusCode::Conflict => {
Err(Error::Fault {
code: res.status,
- message: get_error_message(&mut res).unwrap_or("conflict found".to_owned()),
+ message: get_error_message(&mut res).unwrap_or(
+ "conflict found"
+ .to_owned(),
+ ),
})
}
StatusCode::InternalServerError => {
diff --git a/src/tty.rs b/src/tty.rs
index f4b911f..612a7d2 100644
--- a/src/tty.rs
+++ b/src/tty.rs
@@ -1,6 +1,7 @@
-use std::io::Read;
-use std::io::Cursor;
+
use byteorder::{BigEndian, ReadBytesExt};
+use std::io::Cursor;
+use std::io::Read;
pub struct Tty {
pub stdout: String,
@@ -18,11 +19,13 @@ impl Tty {
match stream.read_exact(&mut header) {
Ok(_) => {
let payload_size: Vec<u8> = header[4..8].to_vec();
- let mut buffer =
- vec![
- 0;
- Cursor::new(&payload_size).read_u32::<BigEndian>().unwrap() as usize
- ];
+ let mut buffer = vec![
+ 0;
+ Cursor::new(&payload_size)
+ .read_u32::<BigEndian>()
+ .unwrap() as
+ usize
+ ];
match stream.read_exact(&mut buffer) {
Ok(_) => {
match header[0] {