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