Trait uritemplate::IntoTemplateVar
[−]
[src]
pub trait IntoTemplateVar { fn into_template_var(self) -> TemplateVar; }
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
fn into_template_var(self) -> TemplateVar
Implementors
impl IntoTemplateVar for TemplateVar
impl<'a> IntoTemplateVar for &'a str
impl IntoTemplateVar for String
impl<'a> IntoTemplateVar for &'a [String]
impl IntoTemplateVar for Vec<String>
impl<'a, 'b> IntoTemplateVar for &'a [&'b str]
impl<'a> IntoTemplateVar for &'a [(String, String)]
impl IntoTemplateVar for Vec<(String, String)>
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str)]
impl<'a> IntoTemplateVar for &'a HashMap<String, String>
impl<'a, 'b, 'c> IntoTemplateVar for &'a HashMap<&'b str, &'c str>
impl<'a> IntoTemplateVar for &'a [String; 0]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 0]
impl<'a> IntoTemplateVar for &'a [(String, String); 0]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 0]
impl<'a> IntoTemplateVar for &'a [String; 1]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 1]
impl<'a> IntoTemplateVar for &'a [(String, String); 1]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 1]
impl<'a> IntoTemplateVar for &'a [String; 2]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 2]
impl<'a> IntoTemplateVar for &'a [(String, String); 2]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 2]
impl<'a> IntoTemplateVar for &'a [String; 3]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 3]
impl<'a> IntoTemplateVar for &'a [(String, String); 3]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 3]
impl<'a> IntoTemplateVar for &'a [String; 4]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 4]
impl<'a> IntoTemplateVar for &'a [(String, String); 4]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 4]
impl<'a> IntoTemplateVar for &'a [String; 5]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 5]
impl<'a> IntoTemplateVar for &'a [(String, String); 5]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 5]
impl<'a> IntoTemplateVar for &'a [String; 6]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 6]
impl<'a> IntoTemplateVar for &'a [(String, String); 6]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 6]
impl<'a> IntoTemplateVar for &'a [String; 7]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 7]
impl<'a> IntoTemplateVar for &'a [(String, String); 7]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 7]
impl<'a> IntoTemplateVar for &'a [String; 8]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 8]
impl<'a> IntoTemplateVar for &'a [(String, String); 8]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 8]
impl<'a> IntoTemplateVar for &'a [String; 9]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 9]
impl<'a> IntoTemplateVar for &'a [(String, String); 9]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 9]
impl<'a> IntoTemplateVar for &'a [String; 10]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 10]
impl<'a> IntoTemplateVar for &'a [(String, String); 10]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 10]
impl<'a> IntoTemplateVar for &'a [String; 11]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 11]
impl<'a> IntoTemplateVar for &'a [(String, String); 11]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 11]
impl<'a> IntoTemplateVar for &'a [String; 12]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 12]
impl<'a> IntoTemplateVar for &'a [(String, String); 12]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 12]
impl<'a> IntoTemplateVar for &'a [String; 13]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 13]
impl<'a> IntoTemplateVar for &'a [(String, String); 13]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 13]
impl<'a> IntoTemplateVar for &'a [String; 14]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 14]
impl<'a> IntoTemplateVar for &'a [(String, String); 14]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 14]
impl<'a> IntoTemplateVar for &'a [String; 15]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 15]
impl<'a> IntoTemplateVar for &'a [(String, String); 15]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 15]
impl<'a> IntoTemplateVar for &'a [String; 16]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 16]
impl<'a> IntoTemplateVar for &'a [(String, String); 16]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 16]
impl<'a> IntoTemplateVar for &'a [String; 17]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 17]
impl<'a> IntoTemplateVar for &'a [(String, String); 17]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 17]
impl<'a> IntoTemplateVar for &'a [String; 18]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 18]
impl<'a> IntoTemplateVar for &'a [(String, String); 18]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 18]
impl<'a> IntoTemplateVar for &'a [String; 19]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 19]
impl<'a> IntoTemplateVar for &'a [(String, String); 19]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 19]
impl<'a> IntoTemplateVar for &'a [String; 20]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 20]
impl<'a> IntoTemplateVar for &'a [(String, String); 20]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 20]
impl<'a> IntoTemplateVar for &'a [String; 21]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 21]
impl<'a> IntoTemplateVar for &'a [(String, String); 21]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 21]
impl<'a> IntoTemplateVar for &'a [String; 22]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 22]
impl<'a> IntoTemplateVar for &'a [(String, String); 22]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 22]
impl<'a> IntoTemplateVar for &'a [String; 23]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 23]
impl<'a> IntoTemplateVar for &'a [(String, String); 23]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 23]
impl<'a> IntoTemplateVar for &'a [String; 24]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 24]
impl<'a> IntoTemplateVar for &'a [(String, String); 24]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 24]
impl<'a> IntoTemplateVar for &'a [String; 25]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 25]
impl<'a> IntoTemplateVar for &'a [(String, String); 25]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 25]
impl<'a> IntoTemplateVar for &'a [String; 26]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 26]
impl<'a> IntoTemplateVar for &'a [(String, String); 26]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 26]
impl<'a> IntoTemplateVar for &'a [String; 27]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 27]
impl<'a> IntoTemplateVar for &'a [(String, String); 27]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 27]
impl<'a> IntoTemplateVar for &'a [String; 28]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 28]
impl<'a> IntoTemplateVar for &'a [(String, String); 28]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 28]
impl<'a> IntoTemplateVar for &'a [String; 29]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 29]
impl<'a> IntoTemplateVar for &'a [(String, String); 29]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 29]
impl<'a> IntoTemplateVar for &'a [String; 30]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 30]
impl<'a> IntoTemplateVar for &'a [(String, String); 30]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 30]
impl<'a> IntoTemplateVar for &'a [String; 31]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 31]
impl<'a> IntoTemplateVar for &'a [(String, String); 31]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 31]
impl<'a> IntoTemplateVar for &'a [String; 32]
impl<'a, 'b> IntoTemplateVar for &'a [&'b str; 32]
impl<'a> IntoTemplateVar for &'a [(String, String); 32]
impl<'a, 'b, 'c> IntoTemplateVar for &'a [(&'b str, &'c str); 32]