Idiomatic way for manipulating a &ByteStream #1044
-
Hello, I am trying to write a little wrapper library around the Below is a small example async fn write_job_output(client: &Client) -> Result<(), Box<dyn std::error::Error>> {
let request = client
.get_job_output()
.account_id("...")
.vault_name("...")
.job_id("...")
.send();
let request = request.await?;
let mut file = File::create("output.json").await?;
file.write_all(request.body().into_inner().bytes().unwrap()).await?; // error here: cannot move out of a shared reference
Ok(())
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Use |
Beta Was this translation helpful? Give feedback.
Use
.body
(without parens) to take ownership. I think you probably want.collect
, or to iterate over the chunks. See example 2 here: https://docs.rs/aws-sdk-glacier/latest/aws_sdk_glacier/primitives/struct.ByteStream.html#getting-data-out-of-a-bytestream