google_maps/traits/query_string.rs
1// -----------------------------------------------------------------------------
2//
3/// Provides a way of converting a request `struct` (such as
4/// `crate::directions::Request` or `crate::elevation::Request`) to a
5/// [URL](https://en.wikipedia.org/wiki/Uniform_Resource_Locator)
6/// [query string](https://en.wikipedia.org/wiki/Query_string) that
7/// can be used in an [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP)
8/// [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request.
9pub trait QueryString {
10 /// Converts a request `struct` (presumably a request type such as
11 /// `crate::directions::Request`) to a
12 /// [URL](https://en.wikipedia.org/wiki/Uniform_Resource_Locator)
13 /// [query string](https://en.wikipedia.org/wiki/Query_string) that
14 /// can be used in an [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP)
15 /// [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET)
16 /// request.
17 ///
18 /// ## Notes
19 ///
20 /// * This function does not validate the request before generating the
21 /// _query string_. However, the superior method that generates the _query
22 /// URL_ does perform validation.
23 ///
24 /// * The query string is the part of the URL after the `?` question mark.
25 /// For example, in the URL `https://example.com/over/there?name=ferret`
26 /// the query string is `name=ferret`
27 ///
28 /// * There's no benefit to working on an owned `Request` struct (i.e. an
29 /// owned `self` versus an borrowed `&self`).
30 /// [percent-encoding](https://crates.io/crates/percent-encoding)
31 /// works on borrowed UTF-8 strings. Other types, such as enums and
32 /// numeric values are converted into strings. Therefore no zero-copy
33 /// operations are possible with an owned `self`.
34 fn query_string(&self) -> String;
35} // trait QueryString