Skip to main content

parse_query_string

Function parse_query_string 

Source
pub fn parse_query_string(qs: &[u8], separator: char) -> Vec<(String, String)>
Expand description

Parse a query string into a vector of (key, value) tuples.

Handles URL encoding and supports multiple values for the same key.

§Arguments

  • qs - The query string bytes
  • separator - The separator character (typically ‘&’)

§Example

let result = parse_query_string(b"foo=1&foo=2&bar=test", '&');
// vec![("foo", "1"), ("foo", "2"), ("bar", "test")]

§Performance

Optimized to minimize allocations by:

  • Processing bytes directly without intermediate String allocation
  • Using custom URL decoder that handles ‘+’ replacement in one pass
  • Pre-allocating result vector