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
use *;
/// A form field destined for Stripe's `application/x-www-form-urlencoded`
/// request body.
///
/// Stripe's REST API takes nested parameters as bracketed keys rather
/// than JSON, so `metadata[order_id]=42` is the wire form. A
/// `FormField` is one such key and value pair; the builder below
/// assembles the whole body.
///
/// Read accessors are generated by `#[derive(Getter)]`.
/// An ordered collection of Stripe form parameters.
///
/// Stripe rejects duplicate keys inside one request, so the builder
/// overwrites a key rather than pushing a second entry, keeping the
/// encoding deterministic: the same builder always produces the same
/// body regardless of the order fields were added.
///
/// The field list is deliberately kept off the generated accessors: a
/// caller holding a mutable `Vec<FormField>` could append a duplicate
/// key and break the one-entry-per-key invariant the encoder relies on,
/// so `get_fields` hands out a slice and the mutable view stays
/// crate-private. Both are written by hand because `#[derive(Getter)]`
/// can express neither a slice nor a `GetterMut` that coexists with it.