Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Aug 7, 2022
1 parent f80a60c commit 41872b2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 30 deletions.
13 changes: 8 additions & 5 deletions object_store/src/aws/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl TryFrom<ListContents> for ObjectMeta {
type Error = crate::Error;

fn try_from(value: ListContents) -> Result<Self> {
Ok(ObjectMeta {
Ok(Self {
location: Path::parse(value.key)?,
last_modified: value.last_modified,
size: value.size,
Expand Down Expand Up @@ -230,7 +230,10 @@ impl S3Client {
}

async fn get_credential(&self) -> Result<Arc<AwsCredential>> {
self.config.credentials.get_credential(&self.client, &self.config.retry_config).await
self.config
.credentials
.get_credential(&self.client, &self.config.retry_config)
.await
}

/// Make an S3 GET request <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html>
Expand Down Expand Up @@ -271,7 +274,7 @@ impl S3Client {
}

/// Make an S3 PUT request <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html>
pub async fn put_request<T: Serialize + ?Sized>(
pub async fn put_request<T: Serialize + ?Sized + Sync>(
&self,
path: &Path,
bytes: Option<Bytes>,
Expand Down Expand Up @@ -302,7 +305,7 @@ impl S3Client {
}

/// Make an S3 Delete request <https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html>
pub async fn delete_request<T: Serialize>(
pub async fn delete_request<T: Serialize + ?Sized + Sync>(
&self,
path: &Path,
query: &T,
Expand Down Expand Up @@ -374,7 +377,7 @@ impl S3Client {
query.push(("list-type", "2"));

if let Some(prefix) = prefix {
query.push(("prefix", prefix.as_ref()))
query.push(("prefix", prefix))
}

let response = self
Expand Down
13 changes: 6 additions & 7 deletions object_store/src/aws/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ struct RequestSigner<'a> {
region: &'a str,
}

const DATE_HEADER: &'static str = "x-amz-date";
const HASH_HEADER: &'static str = "x-amz-content-sha256";
const TOKEN_HEADER: &'static str = "x-amz-security-token";
const AUTH_HEADER: &'static str = "authorization";
const DATE_HEADER: &str = "x-amz-date";
const HASH_HEADER: &str = "x-amz-content-sha256";
const TOKEN_HEADER: &str = "x-amz-security-token";
const AUTH_HEADER: &str = "authorization";

const ALL_HEADERS: &[&'static str; 4] =
&[DATE_HEADER, HASH_HEADER, TOKEN_HEADER, AUTH_HEADER];
const ALL_HEADERS: &[&str; 4] = &[DATE_HEADER, HASH_HEADER, TOKEN_HEADER, AUTH_HEADER];

impl<'a> RequestSigner<'a> {
fn sign(&self, request: &mut Request) {
Expand Down Expand Up @@ -269,7 +268,7 @@ impl CredentialProvider {
retry_config: &RetryConfig,
) -> Result<Arc<AwsCredential>> {
match self {
CredentialProvider::Static { credential } => Ok(Arc::clone(&credential)),
CredentialProvider::Static { credential } => Ok(Arc::clone(credential)),
CredentialProvider::Instance { cache } => {
cache
.get_or_insert_with(|| {
Expand Down
19 changes: 2 additions & 17 deletions object_store/src/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl ObjectStore for AmazonS3 {
.context(MissingContentLengthSnafu)?;

let last_modified = last_modified.to_str().context(BadHeaderSnafu)?;
let last_modified = DateTime::parse_from_rfc2822(last_modified.as_ref())
let last_modified = DateTime::parse_from_rfc2822(last_modified)
.context(InvalidLastModifiedSnafu { last_modified })?
.with_timezone(&Utc);

Expand Down Expand Up @@ -325,7 +325,7 @@ impl CloudMultiPartUploadImpl for S3MultiPartUpload {
/// .with_secret_access_key(SECRET_KEY)
/// .build();
/// ```
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct AmazonS3Builder {
access_key_id: Option<String>,
secret_access_key: Option<String>,
Expand All @@ -337,21 +337,6 @@ pub struct AmazonS3Builder {
allow_http: bool,
}

impl Default for AmazonS3Builder {
fn default() -> Self {
Self {
access_key_id: None,
secret_access_key: None,
region: None,
bucket_name: None,
endpoint: None,
token: None,
retry_config: Default::default(),
allow_http: false,
}
}
}

impl AmazonS3Builder {
/// Create a new [`AmazonS3Builder`] with default values.
pub fn new() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion object_store/src/client/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
};

let next_state = match continuation {
Some(token) => ListState::HasMore(s, token.clone()),
Some(token) => ListState::HasMore(s, token),
None => ListState::Done,
};

Expand Down

0 comments on commit 41872b2

Please sign in to comment.