From eb98b1916c0220e44e2d0f3c869c01a2dd037f60 Mon Sep 17 00:00:00 2001 From: Marc Schreiber Date: Mon, 25 Feb 2019 15:27:21 +0100 Subject: Apply rust format to fix CI checks (#153) --- examples/containercopyinto.rs | 7 +++---- src/lib.rs | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/containercopyinto.rs b/examples/containercopyinto.rs index df56ca2..fb2de50 100644 --- a/examples/containercopyinto.rs +++ b/examples/containercopyinto.rs @@ -11,13 +11,12 @@ fn main() { .nth(2) .expect("Usage: cargo run --example containercopyinto -- "); - - use std::fs::File; - use std::io::prelude::*; + use std::{fs::File, io::prelude::*}; let mut file = File::open(&path).unwrap(); let mut bytes = Vec::new(); - file.read_to_end(&mut bytes).expect("Cannot read file on the localhost."); + file.read_to_end(&mut bytes) + .expect("Cannot read file on the localhost."); let fut = docker .containers() diff --git a/src/lib.rs b/src/lib.rs index e733440..5918205 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -513,17 +513,18 @@ impl<'a, 'b> Container<'a, 'b> { pub fn copy_file_into( &self, path: &Path, - bytes: &[u8] + bytes: &[u8], ) -> impl Future { - let mut ar = tar::Builder::new(Vec::new()); let mut header = tar::Header::new_gnu(); header.set_size(bytes.len() as u64); header.set_mode(0o0644); - ar.append_data(&mut header, + ar.append_data( + &mut header, path.file_name().map(|f| f.to_str().unwrap()).unwrap(), - bytes - ).unwrap(); + bytes, + ) + .unwrap(); let data = ar.into_inner().unwrap(); let body = Some((data, "application/x-tar".parse::().unwrap())); @@ -533,7 +534,10 @@ impl<'a, 'b> Container<'a, 'b> { .finish(); self.docker - .put(&format!("/containers/{}/archive?{}", self.id, path_arg), body) + .put( + &format!("/containers/{}/archive?{}", self.id, path_arg), + body, + ) .map(|_| ()) } } @@ -1004,8 +1008,8 @@ impl Docker { endpoint: &str, body: Option<(B, Mime)>, ) -> impl Future - where - B: Into, + where + B: Into, { self.transport.request(Method::PUT, endpoint, body) } -- cgit v1.2.3