diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-26 15:37:50 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-26 15:37:50 -0500 |
commit | ef2e05804063e3f9696b3996d01f9e500741c04f (patch) | |
tree | 0bcbef98c0a4faeb6e626a7fc517cc968aca7f44 | |
parent | 8e9a5d3f8f2e092ccf06dfd738575d40a1bb791b (diff) |
write bytes instead of converting to string
-rw-r--r-- | ipfs-cli/src/command/block.rs | 4 | ||||
-rw-r--r-- | ipfs-cli/src/command/cat.rs | 5 | ||||
-rw-r--r-- | ipfs-cli/src/command/files.rs | 5 |
3 files changed, 6 insertions, 8 deletions
diff --git a/ipfs-cli/src/command/block.rs b/ipfs-cli/src/command/block.rs index 0a181ad..24fa4eb 100644 --- a/ipfs-cli/src/command/block.rs +++ b/ipfs-cli/src/command/block.rs @@ -11,6 +11,7 @@ use command::{verify_file, EXPECTED_API, EXPECTED_FILE}; use futures::stream::Stream; use ipfs_api::IpfsClient; use std::fs::File; +use std::io::{self, Write}; use tokio_core::reactor::Core; @@ -43,8 +44,7 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { ("get", Some(args)) => { let key = args.value_of("KEY").unwrap(); let req = client.block_get(key).for_each(|chunk| { - println!("{}", String::from_utf8_lossy(&chunk)); - Ok(()) + io::stdout().write_all(&chunk).map_err(From::from) }); core.run(req).expect(EXPECTED_API); diff --git a/ipfs-cli/src/command/cat.rs b/ipfs-cli/src/command/cat.rs index 559bd24..6216bc7 100644 --- a/ipfs-cli/src/command/cat.rs +++ b/ipfs-cli/src/command/cat.rs @@ -10,6 +10,7 @@ use clap::{App, ArgMatches}; use command::EXPECTED_API; use futures::stream::Stream; use ipfs_api::IpfsClient; +use std::io::{self, Write}; use tokio_core::reactor::Core; @@ -25,9 +26,7 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { let path = args.value_of("PATH").unwrap(); let req = client.cat(&path).for_each(|chunk| { - println!("{}", String::from_utf8_lossy(&chunk)); - - Ok(()) + io::stdout().write_all(&chunk).map_err(From::from) }); core.run(req).expect(EXPECTED_API); diff --git a/ipfs-cli/src/command/files.rs b/ipfs-cli/src/command/files.rs index 7cdf3de..00329a9 100644 --- a/ipfs-cli/src/command/files.rs +++ b/ipfs-cli/src/command/files.rs @@ -11,6 +11,7 @@ use command::{verify_file, EXPECTED_API, EXPECTED_FILE}; use futures::stream::Stream; use ipfs_api::IpfsClient; use std::fs::File; +use std::io::{self, Write}; use tokio_core::reactor::Core; @@ -125,9 +126,7 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { ("read", Some(args)) => { let path = args.value_of("PATH").unwrap(); let req = client.files_read(&path).for_each(|chunk| { - println!("{}", String::from_utf8_lossy(&chunk)); - - Ok(()) + io::stdout().write_all(&chunk).map_err(From::from) }); core.run(req).expect(EXPECTED_API); |