uritemplate

Trait IntoTemplateVar

Source
pub trait IntoTemplateVar {
    // Required method
    fn into_template_var(self) -> TemplateVar;
}
Expand description

IntoTemplateVar represents any type that can be converted into a TemplateVar for use as the value of a template variable, such as a String, Vec<String>, or Vec<(String, String)>. Default implementations are available for those three types, as well as the &str versions.

§Example

Here is an example of implementing IntoTemplateVar for your own Address struct. Note that you should probably implement the trait for a reference to your struct, not the actual struct, unless you intend to move the value efficiently.

struct Address {
    city: String,
    state: String
}

impl <'a> IntoTemplateVar for &'a Address {
    fn into_template_var(self) -> TemplateVar {
        TemplateVar::AssociativeArray(vec![
            ("city".to_string(), self.city.clone()),
            ("state".to_string(), self.state.clone())
        ])
    }
}

Now, Address variables can be set as UriTemplate variables.

let address = Address {
    city: "Los Angelos".to_string(),
    state: "California".to_string()
};

let uri = UriTemplate::new("http://example.com/view{?address*}")
    .set("address", &address)
    .build();

assert_eq!(
    uri,
    "http://example.com/view?city=Los%20Angelos&state=California"
);

Required Methods§

Implementations on Foreign Types§

Source§

impl IntoTemplateVar for String

Source§

impl IntoTemplateVar for Vec<(String, String)>

Source§

impl IntoTemplateVar for Vec<String>

Source§

impl<'a> IntoTemplateVar for &'a str

Source§

impl<'a> IntoTemplateVar for &'a HashMap<String, String>

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 0]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 1]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 2]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 3]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 4]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 5]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 6]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 7]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 8]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 9]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 10]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 11]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 12]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 13]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 14]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 15]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 16]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 17]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 18]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 19]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 20]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 21]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 22]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 23]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 24]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 25]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 26]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 27]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 28]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 29]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 30]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 31]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String); 32]

Source§

impl<'a> IntoTemplateVar for &'a [(String, String)]

Source§

impl<'a> IntoTemplateVar for &'a [String; 0]

Source§

impl<'a> IntoTemplateVar for &'a [String; 1]

Source§

impl<'a> IntoTemplateVar for &'a [String; 2]

Source§

impl<'a> IntoTemplateVar for &'a [String; 3]

Source§

impl<'a> IntoTemplateVar for &'a [String; 4]

Source§

impl<'a> IntoTemplateVar for &'a [String; 5]

Source§

impl<'a> IntoTemplateVar for &'a [String; 6]

Source§

impl<'a> IntoTemplateVar for &'a [String; 7]

Source§

impl<'a> IntoTemplateVar for &'a [String; 8]

Source§

impl<'a> IntoTemplateVar for &'a [String; 9]

Source§

impl<'a> IntoTemplateVar for &'a [String; 10]

Source§

impl<'a> IntoTemplateVar for &'a [String; 11]

Source§

impl<'a> IntoTemplateVar for &'a [String; 12]

Source§

impl<'a> IntoTemplateVar for &'a [String; 13]

Source§

impl<'a> IntoTemplateVar for &'a [String; 14]

Source§

impl<'a> IntoTemplateVar for &'a [String; 15]

Source§

impl<'a> IntoTemplateVar for &'a [String; 16]

Source§

impl<'a> IntoTemplateVar for &'a [String; 17]

Source§

impl<'a> IntoTemplateVar for &'a [String; 18]

Source§

impl<'a> IntoTemplateVar for &'a [String; 19]

Source§

impl<'a> IntoTemplateVar for &'a [String; 20]

Source§

impl<'a> IntoTemplateVar for &'a [String; 21]

Source§

impl<'a> IntoTemplateVar for &'a [String; 22]

Source§

impl<'a> IntoTemplateVar for &'a [String; 23]

Source§

impl<'a> IntoTemplateVar for &'a [String; 24]

Source§

impl<'a> IntoTemplateVar for &'a [String; 25]

Source§

impl<'a> IntoTemplateVar for &'a [String; 26]

Source§

impl<'a> IntoTemplateVar for &'a [String; 27]

Source§

impl<'a> IntoTemplateVar for &'a [String; 28]

Source§

impl<'a> IntoTemplateVar for &'a [String; 29]

Source§

impl<'a> IntoTemplateVar for &'a [String; 30]

Source§

impl<'a> IntoTemplateVar for &'a [String; 31]

Source§

impl<'a> IntoTemplateVar for &'a [String; 32]

Source§

impl<'a> IntoTemplateVar for &'a [String]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 0]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 1]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 2]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 3]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 4]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 5]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 6]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 7]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 8]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 9]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 10]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 11]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 12]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 13]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 14]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 15]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 16]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 17]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 18]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 19]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 20]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 21]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 22]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 23]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 24]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 25]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 26]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 27]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 28]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 29]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 30]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 31]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 32]

Source§

impl<'a, 'b> IntoTemplateVar for &'a [&'b str]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a HashMap<&'b str, &'c str>

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 0]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 1]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 2]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 3]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 4]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 5]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 6]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 7]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 8]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 9]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 10]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 11]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 12]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 13]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 14]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 15]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 16]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 17]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 18]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 19]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 20]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 21]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 22]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 23]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 24]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 25]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 26]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 27]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 28]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 29]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 30]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 31]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 32]

Source§

impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str)]

Implementors§