pub struct DataStorage { /* private fields */ }Expand description
The application data directory, resolved once at construction.
Implementations§
Source§impl DataStorage
impl DataStorage
Sourcepub fn new() -> Self
pub fn new() -> Self
Picks the platform data directory and appends owner and app name (from compile-time metadata).
LOCALAPPDATA on Windows, ~/Library/Application Support on macOS,
~/.local/share elsewhere; falls back to . when the environment
variable is missing, so restricted environments still run.
use kasl::libs::data_storage::DataStorage;
let storage = DataStorage::new();
let db_path = storage.get_path("kasl.db")?;
println!("Database path: {:?}", db_path);Sourcepub fn get_path(&self, file_name: &str) -> Result<PathBuf>
pub fn get_path(&self, file_name: &str) -> Result<PathBuf>
Returns the full path for file_name inside the data directory,
creating the directory tree on first use.
use kasl::libs::data_storage::DataStorage;
let storage = DataStorage::new();
let db_path = storage.get_path("kasl.db")?;
// /home/user/.local/share/lacodda/kasl/kasl.db (Linux)
// C:\Users\User\AppData\Local\lacodda\kasl\kasl.db (Windows)
let config_path = storage.get_path("config.json")?;
let session_path = storage.get_path(".jira_session_id")?;Trait Implementations§
Source§impl Clone for DataStorage
impl Clone for DataStorage
Source§fn clone(&self) -> DataStorage
fn clone(&self) -> DataStorage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for DataStorage
impl Default for DataStorage
Source§impl<'de> Deserialize<'de> for DataStorage
impl<'de> Deserialize<'de> for DataStorage
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DataStorage
impl RefUnwindSafe for DataStorage
impl Send for DataStorage
impl Sync for DataStorage
impl Unpin for DataStorage
impl UnsafeUnpin for DataStorage
impl UnwindSafe for DataStorage
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