pub struct AuthData { /* private fields */ }Expand description
This struct holds the username and api_key for the Jira API.
Implementations§
Source§impl AuthData
Implementation of AuthData
impl AuthData
Implementation of AuthData
§Methods
new(username: String, api_key: String) -> AuthData- creates a new instance of AuthDataset_username(username: String)- sets the usernameset_api_key(api_key: String)- sets the api_keyget_username() -> String- gets the usernameget_api_key() -> String- gets the api_keyto_base64() -> String- converts the AuthData to a base64 stringfrom_base64(base64_str: String) -> AuthData- converts a base64 string to an AuthDatawrite_to_file(file: &str) -> Result<(), std::io::Error>- writes the AuthData to a fileread_from_file(file: &str) -> Result<AuthData, std::io::Error>- reads the AuthData from a file
Sourcepub fn new(username: String, api_key: String) -> AuthData
pub fn new(username: String, api_key: String) -> AuthData
Create a new AuthData struct.
§Arguments
- username - The username to be used for authentication.
- api_key - The api_key to be used for authentication.
§Returns
- A new AuthData struct.
§Examples
use jirust_cli::config::config_file::AuthData;
let auth_data = AuthData::new("username".to_string(), "api_key".to_string());Sourcepub fn set_username(&mut self, username: String)
pub fn set_username(&mut self, username: String)
Sourcepub fn set_api_key(&mut self, api_key: String)
pub fn set_api_key(&mut self, api_key: String)
Sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the username and api_key to base64 to be used in the Authorization header of the request.
§Returns
- A base64 encoded string of the username and api_key.
§Examples
use jirust_cli::config::config_file::AuthData;
let auth_data = AuthData::new("username".to_string(), "api_key".to_string());
let base64_encoded = auth_data.to_base64();
assert_eq!(base64_encoded, "dXNlcm5hbWU6YXBpX2tleQ==");Sourcepub fn from_base64(encoded: &str) -> (String, String)
pub fn from_base64(encoded: &str) -> (String, String)
Decode a base64 encoded string to get the username and api_key.
§Arguments
- encoded - The base64 encoded string to be decoded.
§Returns
- A tuple containing the username and api_key.
§Examples
use jirust_cli::config::config_file::AuthData;
let (username, api_key) = AuthData::from_base64("dXNlcm5hbWU6YXBpX2tleQ==");
assert_eq!(username, "username");
assert_eq!(api_key, "api_key");Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthData
impl RefUnwindSafe for AuthData
impl Send for AuthData
impl Sync for AuthData
impl Unpin for AuthData
impl UnwindSafe for AuthData
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