Skip to content

v0.3.0

Compare
Choose a tag to compare
@sebadob sebadob released this 17 Apr 09:59
· 14 commits to main since this release

Any request status returned from any action will be checked early from this version on.
Beforehand, you had to check the status yourself, because you got the full, unmodified S3Response to have the most
amount of freedom. This is still the case, but if the status is any non-success status, an S3Error will be returned
instead of the response itself. This makes it possible to get rid of any dedicated status checking on the client side,
as long as you only care about success or not.
You will still get access to the unmodified S3Response and you could check the status code if you are looking for
something special, but success only is being done internally for even more ease of use.

This makes it possible to go from:

old

let bucket = Bucket::try_from_env()?;

// upload
let res = bucket.put("test.txt", b"Hello S3").await?;
assert!(res.status().is_success());

// get it back
let res = bucket.get("test.txt").await?;
assert!(res.status().is_success());
let body = res.bytes().await?;
assert_eq!(body.as_ref(), b"Hello S3");

new

let bucket = Bucket::try_from_env()?;

// upload
bucket.put("test.txt", b"Hello S3").await?;

// get it back
let res = bucket.get("test.txt").await?;
let body = res.bytes().await?;
assert_eq!(body.as_ref(), b"Hello S3");