pub struct Credentials { /* private fields */ }
Expand description
Credentials for the remote.it API. Remote.it credentials consist of an access key ID and a base64 encoded secret access key.
§Example
You can directly create a new Credentials
struct using the builder pattern:
let credentials = Credentials::builder()
.r3_access_key_id("foo".to_owned())
.r3_secret_access_key("YmFy".to_owned())
.build();
If you enable the credentials_loader
feature, you can also load the credentials from the default, or a custom file:
let creds_from_default_loc = Credentials::load_from_disk().call().unwrap();
let creds_from_custom_loc = Credentials::load_from_disk().custom_credentials_path(PathBuf::from(".env.remoteit")).call().unwrap();
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn access_key_id(&self) -> &str
pub fn access_key_id(&self) -> &str
§Returns
A reference to the r3_access_key_id
Sourcepub fn secret_access_key(&self) -> &str
pub fn secret_access_key(&self) -> &str
§Returns
The base64 encoded r3_secret_access_key
Sourcepub fn builder() -> CredentialsBuilder
pub fn builder() -> CredentialsBuilder
Validated the given secret access key and creates a new Credentials
struct.
§Errors
base64::DecodeError
if the secret access key is not base64 encoded.
§Example
let credentials = Credentials::builder()
.r3_access_key_id("foo".to_owned())
.r3_secret_access_key("YmFy".to_owned())
.build();
Source§impl Credentials
Impl block for credentials_loader related functions.
impl Credentials
Impl block for credentials_loader related functions.
Sourcepub fn load_from_disk() -> CredentialsLoadFromDiskBuilder
pub fn load_from_disk() -> CredentialsLoadFromDiskBuilder
Attempts to load the remote.it credentials from the user’s home directory.
The default location is ~/.remoteit/credentials
.
§Errors
CredentialsLoaderError::HomeDirNotFound
, when thedirs
create cannot find the user’s home directory.CredentialsLoaderError::CouldNotReadCredentials
, when the credentials file could not be parsed by theconfig
crate.
§Example
You can load credentials from the default path (~/.remoteit/credentials
on Unix-like), or provide a custom path.
let credentials_file = Credentials::load_from_disk()
.custom_credentials_path(PathBuf::from("path/to/file")) // Optional
.call();
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
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>,
Source§impl Hash for Credentials
impl Hash for Credentials
Source§impl PartialEq for Credentials
impl PartialEq for Credentials
Source§impl Serialize for Credentials
impl Serialize for 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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.