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 default_credentials_path() -> PathBuf
pub fn default_credentials_path() -> PathBuf
Get the default credentials path (~/.mecha10/credentials.json)
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more