Crate query_string_builder

source ·
Expand description

§A query string builder for percent encoding key-value pairs

This is a tiny helper crate for simplifying the construction of URL query strings. The initial ? question mark is automatically prepended.

§Example

use query_string_builder::QueryString;

let qs = QueryString::dynamic()
            .with_value("q", "🍎 apple")
            .with_value("tasty", true)
            .with_opt_value("color", None::<String>)
            .with_opt_value("category", Some("fruits and vegetables?"));

assert_eq!(
    format!("example.com/{qs}"),
    "example.com/?q=%F0%9F%8D%8E%20apple&tasty=true&category=fruits%20and%20vegetables?"
);

Structs§

  • A query string builder for percent encoding key-value pairs.
  • A query string builder for percent encoding key-value pairs. This variant reduces string allocations as much as possible, defers them to the time of actual rendering, and is capable of storing references.

Type Aliases§