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
impl Credentials
sourcepub 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
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.
sourcepub 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.
pub fn from_keys( access_key_id: impl Into<String>, secret_access_key: impl Into<String>, session_token: Option<String>, ) -> Self
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);
sourcepub fn access_key_id(&self) -> &str
pub fn access_key_id(&self) -> &str
Returns the access key ID.
sourcepub fn secret_access_key(&self) -> &str
pub fn secret_access_key(&self) -> &str
Returns the secret access key.
sourcepub fn expiry(&self) -> Option<SystemTime>
pub fn expiry(&self) -> Option<SystemTime>
Returns the time when the credentials will expire.
sourcepub fn expiry_mut(&mut self) -> &mut Option<SystemTime>
pub fn expiry_mut(&mut self) -> &mut Option<SystemTime>
Returns a mutable reference to the time when the credentials will expire.
sourcepub fn session_token(&self) -> Option<&str>
pub fn session_token(&self) -> Option<&str>
Returns the session token.
source§impl Credentials
impl Credentials
sourcepub fn for_tests() -> Self
Available on crate feature test-util
only.
pub fn for_tests() -> Self
test-util
only.Creates a test Credentials
with no session token.
sourcepub fn for_tests_with_session_token() -> Self
Available on crate feature test-util
only.
pub fn for_tests_with_session_token() -> Self
test-util
only.Creates a test Credentials
that include a session token.
Trait Implementations§
source§impl Clone for Credentials
impl Clone for Credentials
source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Credentials
impl Debug for Credentials
source§impl From<Credentials> for Identity
impl From<Credentials> for Identity
source§fn from(val: Credentials) -> Self
fn from(val: Credentials) -> Self
source§impl PartialEq for Credentials
impl PartialEq for Credentials
source§fn eq(&self, other: &Credentials) -> bool
fn eq(&self, other: &Credentials) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl ProvideCredentials for Credentials
impl ProvideCredentials for Credentials
source§fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'a> ⓘwhere
Self: 'a,
fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'a> ⓘwhere
Self: 'a,
source§fn fallback_on_interrupt(&self) -> Option<Credentials>
fn fallback_on_interrupt(&self) -> Option<Credentials>
impl Eq for Credentials
impl StructuralPartialEq for Credentials
Auto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnwindSafe for Credentials
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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