pub struct SessionManager { /* private fields */ }Expand description
Configurable session manager for storing session data in XDG directories.
This struct allows customization of the application prefix for session storage.
Sessions are stored per-user in the format:
~/.local/share/{app_name}/users/{username}/session.json
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(app_name: impl Into<String>) -> Self
pub fn new(app_name: impl Into<String>) -> Self
Create a new session manager with a custom application name.
§Arguments
app_name- The application name to use as the directory prefix
Sourcepub fn with_data_dir(
app_name: impl Into<String>,
data_dir: impl Into<PathBuf>,
) -> Self
pub fn with_data_dir( app_name: impl Into<String>, data_dir: impl Into<PathBuf>, ) -> Self
Create a session manager rooted in an explicit application data directory.
This is useful on platforms such as Android where the process does not have an XDG home, but the application has a private files directory.
Sourcepub fn get_session_path(&self, username: &str) -> Result<PathBuf>
pub fn get_session_path(&self, username: &str) -> Result<PathBuf>
Get the session file path for a given username using the configured app name.
Returns a path like: ~/.local/share/{app_name}/users/{username}/session.json
§Arguments
username- The Last.fm username
§Returns
Returns the path where the session should be stored, or an error if the XDG data directory cannot be determined.
Sourcepub fn save_session(&self, session: &LastFmEditSession) -> Result<()>
pub fn save_session(&self, session: &LastFmEditSession) -> Result<()>
Sourcepub fn load_session(&self, username: &str) -> Result<LastFmEditSession>
pub fn load_session(&self, username: &str) -> Result<LastFmEditSession>
Sourcepub fn session_exists(&self, username: &str) -> bool
pub fn session_exists(&self, username: &str) -> bool
Sourcepub fn remove_session(&self, username: &str) -> Result<()>
pub fn remove_session(&self, username: &str) -> Result<()>
Trait Implementations§
Source§impl Clone for SessionManager
impl Clone for SessionManager
Source§fn clone(&self) -> SessionManager
fn clone(&self) -> SessionManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more