restless_core/
query.rs

1//! Traits to encode URI query parameters.
2
3use std::borrow::Cow;
4
5/// Determines how a query string is encoded.
6pub trait ToQuery {
7    /// Encode self into a query string.
8    fn encode(&self) -> Cow<'_, str>;
9}
10
11impl ToQuery for () {
12    fn encode(&self) -> Cow<'_, str> {
13        "".into()
14    }
15}
16
17impl ToQuery for String {
18    fn encode(&self) -> Cow<'_, str> {
19        self.as_str().into()
20    }
21}
22
23impl ToQuery for &str {
24    fn encode(&self) -> Cow<'_, str> {
25        (*self).into()
26    }
27}