summaryrefslogtreecommitdiffstats
path: root/examples/containercopyinto.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/containercopyinto.rs')
-rw-r--r--examples/containercopyinto.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/containercopyinto.rs b/examples/containercopyinto.rs
index 63f0a2d..689e7af 100644
--- a/examples/containercopyinto.rs
+++ b/examples/containercopyinto.rs
@@ -1,8 +1,8 @@
use shiplift::Docker;
-use std::env;
-use tokio::prelude::Future;
+use std::{env, fs::File, io::Read};
-fn main() {
+#[tokio::main]
+async fn main() {
let docker = Docker::new();
let path = env::args()
.nth(1)
@@ -11,17 +11,17 @@ fn main() {
.nth(2)
.expect("Usage: cargo run --example containercopyinto -- <local path> <container>");
- 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.");
- let fut = docker
+ if let Err(e) = docker
.containers()
.get(&id)
- .copy_file_into(path, &bytes[..])
- .map_err(|e| eprintln!("Error: {}", e));
- tokio::run(fut);
+ .copy_file_into(path, &bytes)
+ .await
+ {
+ eprintln!("Error: {}", e)
+ }
}