January 2019
Intermediate to advanced
520 pages
14h 32m
English
The service will support complex requests in which you can specify a distribution and parameters. Let's add this enumeration to the source file:
#[derive(Deserialize)]enum RngRequest { Uniform { range: Range<i32>, }, Normal { mean: f64, std_dev: f64, }, Bernoulli { p: f64, },}
You may want to know what the serialized value looks like. serde_derive provides extra attributes, which you can use to tweak the serialization format. The current deserializer expects a RngRequest instance, as follows:
RngRequest::Uniform { range: 1..10,}
This will be represented as the string:
{ "Uniform": { "range": { "start": 1, "end": 10 } } }
If you create your own protocol from scratch, there won't be any problems with the layout, because ...
Read now
Unlock full access