encode_query_allow_reserved

Function encode_query_allow_reserved 

Source
pub fn encode_query_allow_reserved(s: &str) -> impl Iterator<Item = &str>
Expand description

Encode a string to allow it to be added to a URL query, but allowing reserved characters to pass unencoded.

Since this allows & and # to appear in the query value, it should only be used when the URL query contains a single parameter.

ยงExample

use querylizer::{encode_query_allow_reserved, Form};
#[derive(serde::Serialize)]
struct V {
    a: &'static str,
    b: &'static str,
}
let v = V { a: "a red&car~", b: "a/blue=boat" };
let s = Form::to_string("", &v, true, &encode_query_allow_reserved).unwrap();
assert_eq!(s, "a=a%20red&car~&b=a/blue=boat");