pub struct Credential {
pub secret_id: String,
pub secret_key: String,
pub token: Option<String>,
}
Expand description
TencentCloud credentials for API authentication
Fields§
§secret_id: String
Secret ID for authentication
secret_key: String
Secret Key for authentication
token: Option<String>
Session token for temporary credentials (optional)
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn new<S: Into<String>>(
secret_id: S,
secret_key: S,
token: Option<S>,
) -> Self
pub fn new<S: Into<String>>( secret_id: S, secret_key: S, token: Option<S>, ) -> Self
Create a new Credential instance
§Arguments
secret_id
- The secret ID for authenticationsecret_key
- The secret key for authenticationtoken
- Optional session token for temporary credentials
§Examples
use tencentcloud_sms_sdk::Credential;
let credential = Credential::new("your_secret_id", "your_secret_key", None);
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create credentials from environment variables
Reads the following environment variables:
TENCENTCLOUD_SECRET_ID
orTC_SECRET_ID
TENCENTCLOUD_SECRET_KEY
orTC_SECRET_KEY
TENCENTCLOUD_TOKEN
orTC_TOKEN
(optional)
§Examples
use tencentcloud_sms_sdk::Credential;
// Make sure to set environment variables first
// export TENCENTCLOUD_SECRET_ID=your_secret_id
// export TENCENTCLOUD_SECRET_KEY=your_secret_key
let credential = Credential::from_env().unwrap();
Sourcepub fn secret_key(&self) -> &str
pub fn secret_key(&self) -> &str
Get the secret key
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Credential
impl Debug for Credential
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnwindSafe for Credential
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