diff --git a/src/cli.rs b/src/cli.rs index 07e3a1c..88a6e0c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -112,10 +112,7 @@ pub fn eval( let media = content_item.render(render_context, &[mime::STAR_STAR])?; executor::block_on(media.content.try_for_each(|bytes| { - let result = match output.write(&bytes) { - Err(error) => Err(StreamError::from(error)), - Ok(_) => Ok(()), - }; + let result = output.write_all(&bytes).map_err(StreamError::from); async { result } }))?; @@ -152,10 +149,7 @@ pub fn get( let media = content_item.render(render_context, &[accept.unwrap_or(mime::STAR_STAR)])?; executor::block_on(media.content.try_for_each(|bytes| { - let result = match output.write(&bytes) { - Err(error) => Err(StreamError::from(error)), - Ok(_) => Ok(()), - }; + let result = output.write_all(&bytes).map_err(StreamError::from); async { result } }))?; diff --git a/src/content/content_item.rs b/src/content/content_item.rs index 3bfd3e1..90c9b82 100644 --- a/src/content/content_item.rs +++ b/src/content/content_item.rs @@ -251,7 +251,7 @@ mod tests { assert!(str::from_utf8(non_utf8_bytes).is_err()); let mut file = tempfile().expect("Failed to create temporary file"); - file.write(non_utf8_bytes) + file.write_all(non_utf8_bytes) .expect("Failed to write to temporary file"); let static_content = StaticContentItem { media_type: MediaType::from_media_range(mime::APPLICATION_OCTET_STREAM).unwrap(),