- version external APIs
- read (write?) data of older versions
- be agnostic over protocol (but we'll actually use JSON in our examples)
{
"version": 2,
"bla": "foo",
"blub": 5
}
And inspired by serde issue 1137:
#[derive(...)]
struct JsonStuff {
bla: String,
#[serde(added_in = 2)]
blub: u32
}
lolnope
generate code like
mod v1 {
#[derive(Deserizalize)]
struct JsonStuff {
bla: String,
}
}
mod v2 {
#[derive(Deserizalize)]
struct JsonStuff {
bla: String,
blub: u32
}
}
#[derive(Deserizalize)]
enum JsonStuff {
#[serde(rename = "1")]
V1(v1::JsonStuff),
#[serde(rename = "2")]
V2(v2::JsonStuff),
}
Inspired by David on reddit and sozu issue 240.
- Read
(\w+).schema.json
files and generate Rust structs - Read
(\w+).v(\d+).schema.json
files and generate versioned Rust structs