Skip to content
Permalink
Browse files

Apply rust format to fix CI checks

  • Loading branch information...
schrieveslaach committed Feb 25, 2019
1 parent 0ae953c commit 7433021977a837e53aacc0023d369f4204c06b43
Showing with 15 additions and 12 deletions.
  1. +3 −4 examples/containercopyinto.rs
  2. +12 −8 src/lib.rs
@@ -11,13 +11,12 @@ fn main() {
.nth(2)
.expect("Usage: cargo run --example containercopyinto -- <local path> <container>");


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()
@@ -505,17 +505,18 @@ impl<'a, 'b> Container<'a, 'b> {
pub fn copy_file_into(
&self,
path: &Path,
bytes: &[u8]
bytes: &[u8],
) -> impl Future<Item = (), Error = Error> {

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::<Mime>().unwrap()));
@@ -525,7 +526,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(|_| ())
}
}
@@ -996,8 +1000,8 @@ impl Docker {
endpoint: &str,
body: Option<(B, Mime)>,
) -> impl Future<Item = String, Error = Error>
where
B: Into<Body>,
where
B: Into<Body>,
{
self.transport.request(Method::PUT, endpoint, body)
}

0 comments on commit 7433021

Please sign in to comment.
You can’t perform that action at this time.