[][src]Struct rusty_s3::Bucket

pub struct Bucket { /* fields omitted */ }

An S3 bucket

Path style url

let endpoint = "https://eu-west-1.s3.amazonaws.com".parse().expect("endpoint is a valid Url");
let path_style = true;
let name = String::from("rusty-s3");
let region = String::from("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://eu-west-1.s3.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://eu-west-1.s3.amazonaws.com/rusty-s3/duck.jpg");

Domain style url

let endpoint = "https://eu-west-1.s3.amazonaws.com".parse().expect("endpoint is a valid Url");
let path_style = false;
let name = String::from("rusty-s3");
let region = String::from("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.eu-west-1.s3.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.eu-west-1.s3.amazonaws.com/duck.jpg");

Implementations

impl Bucket[src]

pub fn new(
    endpoint: Url,
    path_style: bool,
    name: String,
    region: String
) -> Option<Self>
[src]

Construct a new S3 bucket

pub fn base_url(&self) -> &Url[src]

Get the base url of this s3 Bucket

pub fn name(&self) -> &str[src]

Get the name of this Bucket

pub fn region(&self) -> &str[src]

Get the region of this Bucket

pub fn object_url(&self, object: &str) -> Result<Url, ParseError>[src]

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.

Trait Implementations

impl Clone for Bucket[src]

impl Debug for Bucket[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.