Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move 'sign_with_time' method to 'S3Action' #28

Merged
merged 1 commit into from Oct 26, 2021

Conversation

z4f1r0v
Copy link
Contributor

@z4f1r0v z4f1r0v commented Oct 12, 2021

As per #27, this PR moves the the sign_with_time to the S3Action trait.

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 12, 2021

Hey @paolobarbolini!
I took a stab at this issue. I'm a Rust newbie but this was very much about moving thing around.
Let me know if you have would like something revised :)

@codecov
Copy link

codecov bot commented Oct 12, 2021

Codecov Report

Merging #28 (94903a6) into main (85b30e6) will increase coverage by 0.23%.
The diff coverage is 46.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   91.60%   91.84%   +0.23%     
==========================================
  Files          25       26       +1     
  Lines        1286     1250      -36     
==========================================
- Hits         1178     1148      -30     
+ Misses        108      102       -6     
Impacted Files Coverage Δ
src/actions/create_bucket.rs 82.14% <0.00%> (+7.94%) ⬆️
src/actions/delete_bucket.rs 82.14% <0.00%> (+7.94%) ⬆️
src/actions/delete_object.rs 86.84% <0.00%> (-0.97%) ⬇️
src/actions/multipart_upload/abort.rs 87.17% <0.00%> (-0.92%) ⬇️
src/actions/multipart_upload/create.rs 77.27% <0.00%> (-1.46%) ⬇️
src/actions/multipart_upload/list_parts.rs 93.02% <0.00%> (-0.24%) ⬇️
src/actions/multipart_upload/upload.rs 88.09% <0.00%> (-0.80%) ⬇️
src/actions/put_object.rs 86.84% <0.00%> (-0.97%) ⬇️
src/actions/get_object.rs 93.87% <50.00%> (-0.36%) ⬇️
src/actions/head_object.rs 93.87% <50.00%> (-0.36%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85b30e6...94903a6. Read the comment docs.

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 13, 2021

@paolobarbolini on the first try I had some formatting errors. I have fixed those and resubmitted for review.

@guerinoni
Copy link
Collaborator

@z4f1r0v why many functions are moved? 🤔

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 13, 2021

@guerinoni that's how I read the description of the issue I referenced above. Please correct me if I'm wrong.

Copy link
Owner

@paolobarbolini paolobarbolini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry for the delay in my review. Here's a smallish change which should remove a few now useless lines of code.

Comment on lines +51 to +56
/// Takes the time at which the URL should be signed
/// Used for testing purposes
fn sign_with_time(&self, expires_in: Duration, time: &OffsetDateTime) -> Url;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refers to line 38 but I can't seem to be able to comment a line which hasn't been changed so I'll comment this one instead:

Could you add a default implementation of sign:

    fn sign(&self, expires_in: Duration) -> Url {
        let now = OffsetDateTime::now_utc();
        self.sign_with_time(expires_in, &now)
    }

so that... (continues in the other comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely 👍

Comment on lines -145 to -148
fn sign(&self, expires_in: Duration) -> Url {
let now = OffsetDateTime::now_utc();
self.sign_with_time(expires_in, &now)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...you can remove all of these sign implementations which are all the same?

Basically if a trait has a default implementation for a certain function it'll use it when you do impl Trait for T unless you overwrite it with something else
https://doc.rust-lang.org/book/ch10-02-traits.html#default-implementations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. I'm familiar with the concept. I just did the brainless work of C&P :D

Comment on lines +4 to +5

.idea
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this @guerinoni?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your repo - your rules. I can remove it if is a big problem.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it's ok, maybe for who use this IDE can be handy

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 let's leave it then

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 26, 2021

@paolobarbolini can this be merged?

Copy link
Owner

@paolobarbolini paolobarbolini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paolobarbolini can this be merged?

Yeah sorry I kept forgetting to do the final review. Thank you very much for the PR!

@paolobarbolini paolobarbolini merged commit e7ee122 into paolobarbolini:main Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants