Skip to main content

Crate use_query

Crate use_query 

Source
Expand description

§use-query

Small query string utilities for RustUse.

§Experimental

use-query is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

§Example

use use_query::{append_query_param, get_query_param, parse_query};

let params = parse_query("page=2&draft");

assert_eq!(params.len(), 2);
assert_eq!(get_query_param("page=2&draft", "page").as_deref(), Some("2"));
assert_eq!(append_query_param("page=2", "lang", "en"), "page=2&lang=en");

§Scope

  • Small parsing and building helpers for query strings.
  • Lookup, removal, and append helpers for common tooling tasks.
  • Graceful handling for repeated, empty, or missing values.

§Non-goals

  • Full percent-encoding support.
  • URL parser replacement.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

QueryParam
A parsed query parameter with an optional value.

Functions§

append_query_param
Appends a key-value pair to the query string.
build_query
Builds a query string from ordered parameters.
get_query_param
Returns the first value for the requested key.
has_query_param
Returns true when the query contains the requested key.
parse_query
Parses a query string into ordered key-value pairs.
remove_query_param
Removes every matching key from the query string.