pub struct Credentials { /* private fields */ }Available on crate feature
s3 only.Expand description
An AWS access key pair, with an optional session token.
SigV4 signs each request with it.
resolve gives one from the environment or from the
shared AWS files, and a caller can make one with
Credentials::new.
The Debug output shows the access key id alone. It shows the secret
access key and the session token as <redacted>. No method gives the
secret access key or the session token back.
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn new(
access_key_id: String,
secret_access_key: String,
session_token: Option<String>,
) -> Result<Credentials>
pub fn new( access_key_id: String, secret_access_key: String, session_token: Option<String>, ) -> Result<Credentials>
Returns the key pair of access_key_id and secret_access_key, with
the session token session_token.
§Errors
Error::InvalidInput if a value cannot go into a signature. The
message holds no part of the secret access key or of the session
token. These values are refused:
- an empty access key id, or an access key id with a character that is
not printable ASCII, a space,
/, or, - an empty secret access key, or a secret access key with a control character
- an empty session token, or a session token with a character that is not printable ASCII, or a space
§Examples
use ostrya_remote::s3::Credentials;
let credentials = Credentials::new(
"AKIAIOSFODNN7EXAMPLE".into(),
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY".into(),
None,
)?;
assert_eq!(credentials.access_key_id(), "AKIAIOSFODNN7EXAMPLE");
assert!(!format!("{credentials:?}").contains("EXAMPLEKEY"));Sourcepub fn access_key_id(&self) -> &str
pub fn access_key_id(&self) -> &str
Returns the access key id.
Sourcepub fn has_session_token(&self) -> bool
pub fn has_session_token(&self) -> bool
Returns true if the key pair has a session token.
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Auto Trait Implementations§
impl Forget for Credentials
impl Freeze for Credentials
impl Move for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentialswhere
RawVecInner: Send,
impl Sync for Credentialswhere
RawVecInner: Sync,
impl Unpin for Credentials
impl UnsafeUnpin for Credentials
impl UnwindSafe for Credentialswhere
RawVecInner: UnwindSafe,
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
Mutably borrows from an owned value. Read more