1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Shared handling of the pass-through field every model carries.
//!
//! Request and result models both keep an `extra` map so a worker parameter or
//! a worker field this release does not declare stays reachable. Both therefore
//! need the same rule for what happens when a key in that map is one the model
//! already declares.
use BTreeMap;
use ;
use Value;
/// Serializes a model's declared fields, then adds the pass-through keys they
/// did not already occupy.
///
/// A declared field always wins. On a request that matters because the method a
/// caller reached for is what chose the parameter, and the task is billed
/// whether or not the value was the one they meant. On a result it matters
/// because `Solved` is documented as storable, and a round trip that swaps a
/// decoded token for a pass-through value corrupts the record silently.
///
/// A key the declared fields did not emit stays available: an unset optional is
/// skipped during serialization, never reaches the map, and the pass-through
/// value survives. The Go and Python SDKs resolve the same collision this way.
///
/// Rendering through `serde_json` is what lets the merge compare real keys
/// rather than a stream of events. Every endpoint this crate talks to speaks
/// JSON, so no other format is given up.
pub