pub struct CredentialsService { /* private fields */ }Expand description
Service for managing user credentials
Implementations§
Source§impl CredentialsService
impl CredentialsService
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new CredentialsService with default path (~/.mecha10/credentials.json)
Sourcepub fn with_path(path: PathBuf) -> Self
pub fn with_path(path: PathBuf) -> Self
Create a CredentialsService with a custom credentials path (for testing)
Sourcepub fn credentials_path(&self) -> &PathBuf
pub fn credentials_path(&self) -> &PathBuf
Get the path to the credentials file
Sourcepub fn load(&self) -> Result<Option<Credentials>>
pub fn load(&self) -> Result<Option<Credentials>>
Load credentials from disk
Returns None if credentials file doesn’t exist
Sourcepub fn save(&self, credentials: &Credentials) -> Result<()>
pub fn save(&self, credentials: &Credentials) -> Result<()>
Save credentials to disk
Creates the ~/.mecha10 directory if it doesn’t exist
Sourcepub fn get_api_key(&self) -> Result<Option<String>>
pub fn get_api_key(&self) -> Result<Option<String>>
Get API key from stored credentials
Returns None if not logged in or credentials are invalid
Sourcepub fn is_logged_in(&self) -> bool
pub fn is_logged_in(&self) -> bool
Check if user is logged in (has valid credentials)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CredentialsService
impl RefUnwindSafe for CredentialsService
impl Send for CredentialsService
impl Sync for CredentialsService
impl Unpin for CredentialsService
impl UnwindSafe for CredentialsService
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