pub struct FormField { /* private fields */ }Expand description
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)].
Implementations§
Source§impl FormField
impl FormField
Sourcepub fn percent_encode(raw: &str) -> String
pub fn percent_encode(raw: &str) -> String
Percent-encode a form key or value for Stripe’s request body.
Stripe expects application/x-www-form-urlencoded, which
encodes a space as + and every other reserved character as
%XX over uppercase hex digits. Encoding the bracketed key is
what turns metadata[order_id] into metadata%5Border_id%5D.
§Arguments
&str- the raw key or value to escape.
§Returns
String- the percent-encoded text.
Sourcepub fn is_unreserved(byte: u8) -> bool
pub fn is_unreserved(byte: u8) -> bool
Return whether a byte may appear in a form body unescaped.
This is the RFC 3986 unreserved set plus the five characters
application/x-www-form-urlencoded also passes through:
alphanumerics and - _ . ~. Brackets deliberately fall
outside the set, which is what turns metadata[order_id] into
metadata%5Border_id%5D.
§Arguments
u8- the byte to classify.
§Returns
bool-truewhen the byte needs no percent-escaping.