diff --git a/http/src/v0/block.rs b/http/src/v0/block.rs index fe481c6c..b3b6850a 100644 --- a/http/src/v0/block.rs +++ b/http/src/v0/block.rs @@ -75,7 +75,7 @@ async fn put_query( 1 => Version::V1, _ => return Err(StringError::from("invalid cid version").into()), }; - let mut buf = form + let buf = form .next() .await .ok_or(InvalidMultipartFormData)? @@ -84,7 +84,7 @@ async fn put_query( .await .ok_or(InvalidMultipartFormData)? .map_err(|_| InvalidMultipartFormData)?; - let data = buf.to_bytes().as_ref().to_vec().into_boxed_slice(); + let data = Box::from(buf.bytes()); let digest = hasher(&data); let cid = Cid::new(version, format, digest).map_err(StringError::from)?; let response = PutResponse { diff --git a/http/src/v0/dag.rs b/http/src/v0/dag.rs index b6e3bb44..b15e56cc 100644 --- a/http/src/v0/dag.rs +++ b/http/src/v0/dag.rs @@ -32,7 +32,7 @@ async fn put_query( "sha3-512" => (Sha3_512::digest as fn(&[u8]) -> Multihash, false), _ => return Err(StringError::from("unknown hash").into()), }; - let mut buf = form + let buf = form .next() .await .ok_or(InvalidMultipartFormData)? @@ -41,7 +41,7 @@ async fn put_query( .await .ok_or(InvalidMultipartFormData)? .map_err(|_| InvalidMultipartFormData)?; - let data = buf.to_bytes().as_ref().to_vec().into_boxed_slice(); + let data = Box::from(buf.bytes()); let digest = hasher(&data); let cid = if v0_fmt && v0_hash { // this is quite ugly way but apparently js-ipfs generates a v0 cid for this combination