Expand description
§app-path
Create file paths relative to your executable for truly portable applications.
§Quick Start
use app_path::AppPath;
use std::convert::TryFrom;
// Create paths relative to your executable
let config = AppPath::try_new("config.toml")?;
let data = AppPath::try_new("data/users.db")?;
// Alternative: Use TryFrom for ergonomic conversions
let logs = AppPath::try_from("logs/app.log")?;
let cache_file = "cache.json".to_string();
let cache = AppPath::try_from(cache_file)?;
// Get the paths for use with standard library functions
println!("Config: {}", config.path().display());
println!("Data: {}", data.path().display());
// Check existence and create directories
if !logs.exists() {
logs.create_dir_all()?;
}
Structs§
- AppPath
- Creates paths relative to the executable location for applications.