[][src]Struct s3::credentials::Credentials

pub struct Credentials {
    pub access_key: String,
    pub secret_key: String,
    pub token: Option<String>,
    // some fields omitted
}

AWS access credentials: access key, secret key, and optional token.

Example

Loads from the standard AWS credentials file with the given profile name, defaults to "default".

use s3::credentials::Credentials;

// Load credentials from `[default]` profile
let credentials = Credentials::default();

// Also loads credentials from `[default]` profile
let credentials = Credentials::new(None, None, None, None);

// Load credentials from `[my-profile]` profile
let credentials = Credentials::new(None, None, None, Some("my-profile".into()));

Credentials may also be initialized directly or by the following environment variables:

  • AWS_ACCESS_KEY_ID,
  • AWS_SECRET_ACCESS_KEY
  • AWS_SESSION_TOKEN

The order of preference is arguments, then environment, and finally AWS credentials file.

use s3::credentials::Credentials;

// Load credentials directly
let access_key = String::from("AKIAIOSFODNN7EXAMPLE");
let secret_key = String::from("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
let credentials = Credentials::new(Some(access_key), Some(secret_key), None, None);

// Load credentials from the environment
use std::env;
env::set_var("AWS_ACCESS_KEY_ID", "AKIAIOSFODNN7EXAMPLE");
env::set_var("AWS_SECRET_ACCESS_KEY", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
let credentials = Credentials::new(None, None, None, None);

Fields

access_key: String

AWS public access key.

secret_key: String

AWS secret key.

token: Option<String>

Temporary token issued by AWS service.

Methods

impl Credentials[src]

pub fn new(
    access_key: Option<String>,
    secret_key: Option<String>,
    token: Option<String>,
    profile: Option<String>
) -> Credentials
[src]

Initialize Credentials directly with key ID, secret key, and optional token.

pub fn from_profile(section: Option<String>) -> S3Result<Credentials>[src]

Trait Implementations

impl Clone for Credentials[src]

impl Debug for Credentials[src]

impl Default for Credentials[src]

impl Eq for Credentials[src]

impl PartialEq<Credentials> for Credentials[src]

impl StructuralEq for Credentials[src]

impl StructuralPartialEq for Credentials[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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,