macro_rules! toml {
($data:ty, $dir:expr, $project_directory:expr, $sub_directories:expr, $file_name:expr) => { ... };
}Available on crate feature
toml only.Expand description
Implement the Toml trait
File extension is toml and is automatically appended.
§Input
These are the inputs you need to provide to implement Toml.
| Variable | Description | Related Trait Constant | Type | Example |
|---|---|---|---|---|
$data | Identifier of the data to implement for | struct or enum | MyState | |
$dir | Which OS directory to use | Toml::OS_DIRECTORY | Dir | Dir::Data |
$project_directory | The name of the top project folder | Toml::PROJECT_DIRECTORY | &str | "MyProject" |
$sub_directories | (Optional) sub-directories before file | Toml::SUB_DIRECTORIES | &str | "some/dirs" |
$file_name | The file name to use | Toml::FILE_NAME | &str | "state" |
§Example
use serde::{Serialize,Deserialize};
use disk::*;
toml!(State, Dir::Data, "MyProject", "some/dirs", "state");
#[derive(Serialize,Deserialize)]
struct State {
string: String,
number: u32,
}This example would be located at ~/.local/share/myproject/some/dirs/state.toml.