s3 0.1.23

A lean, modern, unofficial S3-compatible client for Rust.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::io::Read;

use crate::error::{Error, Result};
use crate::transport::blocking_transport::BlockingResponseBody;

pub(crate) fn read_body_bytes(body: BlockingResponseBody) -> Result<Vec<u8>> {
    let mut out = Vec::new();
    body.into_reader()
        .read_to_end(&mut out)
        .map_err(|e| Error::transport("failed to read response body", Some(Box::new(e))))?;
    Ok(out)
}

pub(crate) fn read_body_string(body: BlockingResponseBody) -> Result<String> {
    let bytes = read_body_bytes(body)?;
    Ok(String::from_utf8_lossy(&bytes).to_string())
}