macro_rules! StoredKey {
($key_name:ident, Value = $val:ty, Path = $path:expr, Default = $default:expr, Serialize = $serialize:expr, Deserialize = $deserialize:expr) => { ... };
}Expand description
Example usage:
struct ExampleKey;
StoredKey! {
ExampleKey,
Value = i32,
Path = "somedir",
Default = 1111_i32,
Serialize = |val: &i32| val.to_string().into_bytes(),
Deserialize = |contents: &[u8]| {
String::from_utf8(contents.to_vec())
.unwrap()
.parse()
.unwrap()
}
}