pub trait QueryString {
// Required method
fn query_string(&self) -> String;
}
Expand description
Provides a way of converting a request struct
(such as
crate::directions::Request
or crate::elevation::Request
) to a
URL
query string that
can be used in an HTTP
GET request.
Required Methods§
Sourcefn query_string(&self) -> String
fn query_string(&self) -> String
Converts a request struct
(presumably a request type such as
crate::directions::Request
) to a
URL
query string that
can be used in an HTTP
GET
request.
§Notes
-
This function does not validate the request before generating the query string. However, the superior method that generates the query URL does perform validation.
-
The query string is the part of the URL after the
?
question mark. For example, in the URLhttps://example.com/over/there?name=ferret
the query string isname=ferret
-
There’s no benefit to working on an owned
Request
struct (i.e. an ownedself
versus an borrowed&self
). percent-encoding works on borrowed UTF-8 strings. Other types, such as enums and numeric values are converted into strings. Therefore no zero-copy operations are possible with an ownedself
.