[−][src]Struct s3::bucket::Bucket
Example
use s3::bucket::Bucket; use s3::credentials::Credentials; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default(); let bucket = Bucket::new(bucket_name, region, credentials);
Fields
name: String
region: Region
credentials: Credentials
extra_headers: Headers
extra_query: Query
Methods
impl Bucket
[src]
impl Bucket
pub fn new(name: &str, region: Region, credentials: Credentials) -> Bucket
[src]
pub fn new(name: &str, region: Region, credentials: Credentials) -> Bucket
Instantiate a new Bucket
.
Example
use s3::bucket::Bucket; use s3::credentials::Credentials; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default(); let bucket = Bucket::new(bucket_name, region, credentials);
pub fn get(&self, path: &str) -> S3Result<(Vec<u8>, u32)>
[src]
pub fn get(&self, path: &str) -> S3Result<(Vec<u8>, u32)>
Gets file from an S3 path.
Example:
use s3::bucket::Bucket; use s3::credentials::Credentials; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default(); let bucket = Bucket::new(bucket_name, region, credentials); let (data, code) = bucket.get("/test.file").unwrap(); println!("Code: {}\nData: {:?}", code, data);
pub fn delete(&self, path: &str) -> S3Result<(Vec<u8>, u32)>
[src]
pub fn delete(&self, path: &str) -> S3Result<(Vec<u8>, u32)>
Delete file from an S3 path.
Example:
use s3::bucket::Bucket; use s3::credentials::Credentials; let bucket_name = &"rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default(); let bucket = Bucket::new(bucket_name, region, credentials); let (_, code) = bucket.delete("/test.file").unwrap(); assert_eq!(204, code);
pub fn put(
&self,
path: &str,
content: &[u8],
content_type: &str
) -> S3Result<(Vec<u8>, u32)>
[src]
pub fn put(
&self,
path: &str,
content: &[u8],
content_type: &str
) -> S3Result<(Vec<u8>, u32)>
Put into an S3 bucket.
Example
use s3::bucket::Bucket; use s3::credentials::Credentials; let bucket_name = &"rust-s3-test"; let aws_access = &"access_key"; let aws_secret = &"secret_key"; let bucket_name = &"rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default(); let bucket = Bucket::new(bucket_name, region, credentials); let content = "I want to go to S3".as_bytes(); let (_, code) = bucket.put("/test.file", content, "text/plain").unwrap(); assert_eq!(201, code);
pub fn list(
&self,
prefix: &str,
delimiter: Option<&str>
) -> S3Result<Vec<(ListBucketResult, u32)>>
[src]
pub fn list(
&self,
prefix: &str,
delimiter: Option<&str>
) -> S3Result<Vec<(ListBucketResult, u32)>>
List the contents of an S3 bucket.
Example
use std::str; use s3::bucket::Bucket; use s3::credentials::Credentials; let bucket_name = &"rust-s3-test"; let aws_access = &"access_key"; let aws_secret = &"secret_key"; let bucket_name = &"rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default(); let bucket = Bucket::new(bucket_name, region, credentials); let results = bucket.list("/", Some("/")).unwrap(); for (list, code) in results { assert_eq!(200, code); println!("{:?}", list); }
pub fn name(&self) -> &str
[src]
pub fn name(&self) -> &str
Get a reference to the name of the S3 bucket.
pub fn host(&self) -> &str
[src]
pub fn host(&self) -> &str
Get a reference to the hostname of the S3 API endpoint.
pub fn scheme(&self) -> &str
[src]
pub fn scheme(&self) -> &str
pub fn region(&self) -> Region
[src]
pub fn region(&self) -> Region
Get the region this object will connect to.
pub fn access_key(&self) -> &str
[src]
pub fn access_key(&self) -> &str
Get a reference to the AWS access key.
pub fn secret_key(&self) -> &str
[src]
pub fn secret_key(&self) -> &str
Get a reference to the AWS secret key.
pub fn token(&self) -> Option<&str>
[src]
pub fn token(&self) -> Option<&str>
Get a reference to the AWS token.
pub fn credentials(&self) -> &Credentials
[src]
pub fn credentials(&self) -> &Credentials
Get a reference to the full Credentials
object used by this Bucket
.
pub fn set_credentials(&mut self, credentials: Credentials) -> Credentials
[src]
pub fn set_credentials(&mut self, credentials: Credentials) -> Credentials
Change the credentials used by the Bucket, returning the existing credentials.
pub fn add_header(&mut self, key: &str, value: &str)
[src]
pub fn add_header(&mut self, key: &str, value: &str)
Add an extra header to send with requests to S3.
Add an extra header to send with requests. Note that the library already sets a number of headers - headers set with this method will be overridden by the library headers:
- Host
- Content-Type
- Date
- Content-Length
- Authorization
- X-Amz-Content-Sha256
- X-Amz-Date
pub fn extra_headers(&self) -> &Headers
[src]
pub fn extra_headers(&self) -> &Headers
Get a reference to the extra headers to be passed to the S3 API.
pub fn extra_headers_mut(&mut self) -> &mut Headers
[src]
pub fn extra_headers_mut(&mut self) -> &mut Headers
Get a mutable reference to the extra headers to be passed to the S3 API.
pub fn add_query(&mut self, key: &str, value: &str)
[src]
pub fn add_query(&mut self, key: &str, value: &str)
Add an extra query pair to the URL used for S3 API access.
pub fn extra_query(&self) -> &Query
[src]
pub fn extra_query(&self) -> &Query
Get a reference to the extra query pairs to be passed to the S3 API.
pub fn extra_query_mut(&mut self) -> &mut Query
[src]
pub fn extra_query_mut(&mut self) -> &mut Query
Get a mutable reference to the extra query pairs to be passed to the S3 API.
Trait Implementations
impl Clone for Bucket
[src]
impl Clone for Bucket
fn clone(&self) -> Bucket
[src]
fn clone(&self) -> Bucket
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq<Bucket> for Bucket
[src]
impl PartialEq<Bucket> for Bucket
fn eq(&self, other: &Bucket) -> bool
[src]
fn eq(&self, other: &Bucket) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Bucket) -> bool
[src]
fn ne(&self, other: &Bucket) -> bool
This method tests for !=
.
impl Eq for Bucket
[src]
impl Eq for Bucket
impl Debug for Bucket
[src]
impl Debug for Bucket
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<T> Erased for T
impl<T> Erased for T