rust-uritemplate
rust-uritemplate
is a Rust implementation of
RFC6570 - URI Template that can process
URI Templates up to and including ones designated as Level 4 by the
specification. It passes all of the tests in the
uritemplate-test test
suite.
Basic Usage
Variable setting can be chained for nice, clean code.
let uri = new
.set
.set
.set
.build;
assert_eq!;
It is not possible to set a variable to the value "undefined". Instead, simply delete the variable if you have already set it.
let mut t = new;
t.set;
assert_eq!;
t.delete;
assert_eq!;
The delete
function returns true
if the variable existed and false
otherwise.
Supported Types
Any type that implements IntoTemplateVar
can be set as the value of a
UriTemplate
variable. The following implementations are provided by default
for each type of variable:
- Scalar Values:
String
,&str
- Lists:
Vec<String>
,&[String]
,&[str]
- Associative Arrays:
Vec<(String, String)>
,&[(String, String)]
,&[(&str, &str)]
,&HashMap<String, String>
In addition, you can implement IntoTemplateVar
for your own types. View the
documentation for IntoTemplateVar
for information on how that works.