Crate microxdg

Source
Expand description

An XDG Base Directory Specification Rust library that aims to be conservative on memory allocation and overall memory footprint.

§Examples

The following example illustrates how to retrieve the user-specific XDG configuration base directory:

use microxdg::{Xdg, XdgError};

fn main() -> Result<(), XdgError> {
    let xdg = Xdg::new()?;
    let config_dir = xdg.config()?;
    debug_assert_eq!(Path::new("/home/user/.config"), &config_dir);

    /* Do something with `config_dir`... */

    Ok(())
}

One may also want to retrieve the user-specific XDG state subdirectories relative to a certain application:

use microxdg::{XdgApp, XdgError};

fn main() -> Result<(), XdgError> {
    let xdg = XdgApp::new("app_name")?;
    let app_state_dir = xdg.app_state()?;
    debug_assert_eq!(Path::new("/home/user/.local/state/app_name"), &app_state_dir);

    /* Do something with `app_state_dir`... */

    Ok(())
}

Structs§

Xdg
An implementation of the XDG Base Directory Specification.
XdgApp
An implementation of the XDG Base Directory Specification with extent to application-specific subdirectories.

Enums§

XdgError
XDG Base Directory Specification errors.