Struct aws_credential_types::Credentials

source ·
pub struct Credentials(/* private fields */);
Expand description

AWS SDK Credentials

An opaque struct representing credentials that may be used in an AWS SDK, modeled on the CRT credentials implementation.

When Credentials is dropped, its contents are zeroed in memory. Credentials uses an interior Arc to ensure that even when cloned, credentials don’t exist in multiple memory locations.

Implementations§

source§

impl Credentials

source

pub fn new( access_key_id: impl Into<String>, secret_access_key: impl Into<String>, session_token: Option<String>, expires_after: Option<SystemTime>, provider_name: &'static str, ) -> Self

Creates Credentials.

This is intended to be used from a custom credentials provider implementation. It is NOT secure to hardcode credentials into your application.

source

pub fn from_keys( access_key_id: impl Into<String>, secret_access_key: impl Into<String>, session_token: Option<String>, ) -> Self

Available on crate feature hardcoded-credentials only.

Creates Credentials from hardcoded access key, secret key, and session token.

Note: In general, you should prefer to use the credential providers that come with the AWS SDK to get credentials. It is NOT secure to hardcode credentials into your application. If you’re writing a custom credentials provider, then use Credentials::new instead of this.

This function requires the hardcoded-credentials feature to be enabled.

Credentials implement ProvideCredentials directly, so no custom provider implementation is required when wiring these up to a client:

use aws_credential_types::Credentials;

let creds = Credentials::from_keys("akid", "secret_key", None);
let config = Config::builder()
    .credentials_provider(creds)
    .build();
let client = Client::from_conf(config);
source

pub fn access_key_id(&self) -> &str

Returns the access key ID.

source

pub fn secret_access_key(&self) -> &str

Returns the secret access key.

source

pub fn expiry(&self) -> Option<SystemTime>

Returns the time when the credentials will expire.

source

pub fn expiry_mut(&mut self) -> &mut Option<SystemTime>

Returns a mutable reference to the time when the credentials will expire.

source

pub fn session_token(&self) -> Option<&str>

Returns the session token.

source§

impl Credentials

source

pub fn for_tests() -> Self

Available on crate feature test-util only.

Creates a test Credentials with no session token.

source

pub fn for_tests_with_session_token() -> Self

Available on crate feature test-util only.

Creates a test Credentials that include a session token.

Trait Implementations§

source§

impl Clone for Credentials

source§

fn clone(&self) -> Credentials

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Credentials

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Credentials> for Identity

source§

fn from(val: Credentials) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Credentials

source§

fn eq(&self, other: &Credentials) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ProvideCredentials for Credentials

source§

fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'a>
where Self: 'a,

Returns a future that provides credentials.
source§

fn fallback_on_interrupt(&self) -> Option<Credentials>

Returns fallback credentials. Read more
source§

impl Eq for Credentials

source§

impl StructuralPartialEq for Credentials

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more