Struct infinitree_backends::Bucket
source · pub struct Bucket { /* private fields */ }
Expand description
An S3 bucket
Path style url
let endpoint = "https://s3.dualstack.eu-west-1.amazonaws.com".parse().expect("endpoint is a valid Url");
let path_style = UrlStyle::Path;
let name = "rusty-s3";
let region = "eu-west-1";
let bucket = Bucket::new(endpoint, path_style, name, region).expect("Url has a valid scheme and host");
assert_eq!(bucket.base_url().as_str(), "https://s3.dualstack.eu-west-1.amazonaws.com/rusty-s3/");
assert_eq!(bucket.name(), "rusty-s3");
assert_eq!(bucket.region(), "eu-west-1");
assert_eq!(bucket.object_url("duck.jpg").expect("url is valid").as_str(), "https://s3.dualstack.eu-west-1.amazonaws.com/rusty-s3/duck.jpg");
Domain style url
let endpoint = "https://s3.dualstack.eu-west-1.amazonaws.com".parse().expect("endpoint is a valid Url");
let path_style = UrlStyle::VirtualHost;
let name = "rusty-s3";
let region = "eu-west-1";
let bucket = Bucket::new(endpoint, path_style, name, region).expect("Url has a valid scheme and host");
assert_eq!(bucket.base_url().as_str(), "https://rusty-s3.s3.dualstack.eu-west-1.amazonaws.com/");
assert_eq!(bucket.name(), "rusty-s3");
assert_eq!(bucket.region(), "eu-west-1");
assert_eq!(bucket.object_url("duck.jpg").expect("url is valid").as_str(), "https://rusty-s3.s3.dualstack.eu-west-1.amazonaws.com/duck.jpg");
Implementations§
source§impl Bucket
impl Bucket
sourcepub fn new(
endpoint: Url,
path_style: UrlStyle,
name: impl Into<Cow<'static, str>>,
region: impl Into<Cow<'static, str>>
) -> Result<Bucket, BucketError>
pub fn new( endpoint: Url, path_style: UrlStyle, name: impl Into<Cow<'static, str>>, region: impl Into<Cow<'static, str>> ) -> Result<Bucket, BucketError>
Construct a new S3 bucket
sourcepub fn object_url(&self, object: &str) -> Result<Url, ParseError>
pub fn object_url(&self, object: &str) -> Result<Url, ParseError>
Generate an url to an object of this Bucket
This is not a signed url, it’s just the starting point for generating an url to an S3 object.
source§impl Bucket
impl Bucket
sourcepub fn create_bucket<'a>(
&'a self,
credentials: &'a Credentials
) -> CreateBucket<'a>
pub fn create_bucket<'a>( &'a self, credentials: &'a Credentials ) -> CreateBucket<'a>
Create a new bucket.
See CreateBucket
for more details.
sourcepub fn delete_bucket<'a>(
&'a self,
credentials: &'a Credentials
) -> DeleteBucket<'a>
pub fn delete_bucket<'a>( &'a self, credentials: &'a Credentials ) -> DeleteBucket<'a>
Delete a bucket.
See DeleteBucket
for more details.
source§impl Bucket
impl Bucket
sourcepub fn head_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> HeadObject<'a>
pub fn head_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str ) -> HeadObject<'a>
Retrieve an object’s metadata from S3, using a HEAD
request.
See HeadObject
for more details.
sourcepub fn head_bucket<'a>(
&'a self,
credentials: Option<&'a Credentials>
) -> HeadBucket<'a>
pub fn head_bucket<'a>( &'a self, credentials: Option<&'a Credentials> ) -> HeadBucket<'a>
Retrieve an bucket’s metadata from S3, using a HEAD
request.
See HeadBucket
for more details.
sourcepub fn get_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> GetObject<'a>
pub fn get_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str ) -> GetObject<'a>
Retrieve an object from S3, using a GET
request.
See GetObject
for more details.
sourcepub fn put_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> PutObject<'a>
pub fn put_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str ) -> PutObject<'a>
Upload a file to S3, using a PUT
request.
See PutObject
for more details.
sourcepub fn delete_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> DeleteObject<'a>
pub fn delete_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str ) -> DeleteObject<'a>
Delete an object from S3, using a DELETE
request.
See DeleteObject
for more details.
source§impl Bucket
impl Bucket
sourcepub fn upload_part<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
part_number: u16,
upload_id: &'a str
) -> UploadPart<'a>
pub fn upload_part<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, part_number: u16, upload_id: &'a str ) -> UploadPart<'a>
Upload a part to a previously created multipart upload.
See UploadPart
for more details.
sourcepub fn abort_multipart_upload<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str
) -> AbortMultipartUpload<'a>
pub fn abort_multipart_upload<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, upload_id: &'a str ) -> AbortMultipartUpload<'a>
Abort multipart upload.
See AbortMultipartUpload
for more details.
Trait Implementations§
source§impl PartialEq<Bucket> for Bucket
impl PartialEq<Bucket> for Bucket
impl Eq for Bucket
impl StructuralEq for Bucket
impl StructuralPartialEq for Bucket
Auto Trait Implementations§
impl RefUnwindSafe for Bucket
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnwindSafe for Bucket
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.