pub enum Credentials {
AccessToken {
access_token: String,
},
Authorization {
auth: String,
},
UsernamePassword {
username: String,
password: String,
},
UsernamePasswordDigest {
username: String,
digest: String,
passworddigest: String,
},
Anonymous,
}
Expand description
Authentication credentials used for pCloud API requests.
Variants§
AccessToken
Uses a personal access token.
Authorization
Uses an authorization token.
UsernamePassword
Uses a username and password for authentication.
UsernamePasswordDigest
Uses a username and password for authentication.
Anonymous
Without authentication, used for getting a digest
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn access_token(value: impl Into<String>) -> Self
pub fn access_token(value: impl Into<String>) -> Self
Creates credentials using an access token.
Creates credentials using an authorization token.
Sourcepub fn username_password(
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn username_password( username: impl Into<String>, password: impl Into<String>, ) -> Self
Creates credentials using a username and password.
pub fn username_password_digest( username: impl Into<String>, digest: impl Into<String>, password: impl AsRef<[u8]>, ) -> Self
Source§impl Credentials
impl Credentials
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates a credential based on the environment variables
When PCLOUD_ACCESS_TOKEN
is set, a Credentials::AccessToken
will be created.
When PCLOUD_USERNAME
and PCLOUD_PASSWORD
are set, a Credentials::UsernamePassword
will be created.
If none are set, Credentials::Anonymous
is returned.
use pcloud::Credentials;
match Credentials::from_env() {
Credentials::AccessToken { .. } => println!("uses an access token"),
Credentials::UsernamePassword { .. } => println!("uses a username and a password"),
_ => eprintln!("no credentials provided"),
}
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
Returns a copy 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 Credentials
impl Debug for Credentials
Source§impl<'de> Deserialize<'de> for Credentials
impl<'de> Deserialize<'de> for Credentials
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more