refactor: Use std::io to shorten lines

pull/24376/head
Jake Goulding 2020-06-26 20:49:32 -04:00
parent 00805a0225
commit f2003fbf78
1 changed files with 5 additions and 6 deletions

View File

@ -20,10 +20,9 @@ use rusoto_core::ByteStream;
use rusoto_credential::ChainProvider; use rusoto_credential::ChainProvider;
use rusoto_s3::S3; use rusoto_s3::S3;
use snafu::{ensure, futures::TryStreamExt as _, OptionExt, ResultExt, Snafu}; use snafu::{ensure, futures::TryStreamExt as _, OptionExt, ResultExt, Snafu};
use std::{collections::BTreeMap, fmt, io};
use tokio::sync::RwLock; use tokio::sync::RwLock;
use std::{collections::BTreeMap, fmt};
/// Universal interface to multiple object store services. /// Universal interface to multiple object store services.
#[derive(Debug)] #[derive(Debug)]
pub struct ObjectStore(ObjectStoreIntegration); pub struct ObjectStore(ObjectStoreIntegration);
@ -47,7 +46,7 @@ impl ObjectStore {
/// Save the provided bytes to the specified location. /// Save the provided bytes to the specified location.
pub async fn put<S>(&self, location: &str, bytes: S, length: usize) -> Result<()> pub async fn put<S>(&self, location: &str, bytes: S, length: usize) -> Result<()>
where where
S: Stream<Item = std::io::Result<Bytes>> + Send + Sync + 'static, S: Stream<Item = io::Result<Bytes>> + Send + Sync + 'static,
{ {
use ObjectStoreIntegration::*; use ObjectStoreIntegration::*;
match &self.0 { match &self.0 {
@ -120,7 +119,7 @@ impl GoogleCloudStorage {
/// Save the provided bytes to the specified location. /// Save the provided bytes to the specified location.
async fn put<S>(&self, location: &str, bytes: S, length: usize) -> InternalResult<()> async fn put<S>(&self, location: &str, bytes: S, length: usize) -> InternalResult<()>
where where
S: Stream<Item = std::io::Result<Bytes>> + Send + Sync + 'static, S: Stream<Item = io::Result<Bytes>> + Send + Sync + 'static,
{ {
let temporary_non_streaming = bytes let temporary_non_streaming = bytes
.map_ok(|b| bytes::BytesMut::from(&b[..])) .map_ok(|b| bytes::BytesMut::from(&b[..]))
@ -242,7 +241,7 @@ impl AmazonS3 {
/// Save the provided bytes to the specified location. /// Save the provided bytes to the specified location.
async fn put<S>(&self, location: &str, bytes: S, length: usize) -> InternalResult<()> async fn put<S>(&self, location: &str, bytes: S, length: usize) -> InternalResult<()>
where where
S: Stream<Item = std::io::Result<Bytes>> + Send + Sync + 'static, S: Stream<Item = io::Result<Bytes>> + Send + Sync + 'static,
{ {
let bytes = ByteStream::new_with_size(bytes, length); let bytes = ByteStream::new_with_size(bytes, length);
@ -355,7 +354,7 @@ impl InMemory {
/// Save the provided bytes to the specified location. /// Save the provided bytes to the specified location.
async fn put<S>(&self, location: &str, bytes: S, length: usize) -> InternalResult<()> async fn put<S>(&self, location: &str, bytes: S, length: usize) -> InternalResult<()>
where where
S: Stream<Item = std::io::Result<Bytes>> + Send + Sync + 'static, S: Stream<Item = io::Result<Bytes>> + Send + Sync + 'static,
{ {
let content = bytes let content = bytes
.map_ok(|b| bytes::BytesMut::from(&b[..])) .map_ok(|b| bytes::BytesMut::from(&b[..]))