# uri-template
A Rust Implementation of [RFC6570](https://www.rfc-editor.org/rfc/rfc6570) URI Template with parsing, expansion, compile-time checked macros, and `no_std` support.
```toml
uri-template = { version = "0.1.0", features = ["macros"] }
```
## Features
- Full support of [RFC6570](https://www.rfc-editor.org/rfc/rfc6570) Level 4 URI Template.
- Runtime parsing and expansion.
- Compile-time checked procedural macros.
- `no_std` support.
## Quick Start
Basic usage:
```rust
use uri_template::{HashValues, UriTemplate};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let template = UriTemplate::new("https://example.com/{username}/items{?page,pageSize}")?;
let mut values = HashValues::new();
values.insert("username", "foo");
values.insert("page", 1);
values.insert("pageSize", 20);
let uri = template.expand(&values)?;
assert_eq!(uri, "https://example.com/foo/items?page=1&pageSize=20");
Ok(())
}
```
**Compile-time checked** templates:
```rust
use uri_template::{HashValues, uri_template};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let template = uri_template!("https://example.com/{username}/items{?page,pageSize}");
let mut values = HashValues::new();
values.insert("username", "foo");
values.insert("page", 1);
values.insert("pageSize", 20);
let uri = template.expand(&values)?;
assert_eq!(uri, "https://example.com/foo/items?page=1&pageSize=20");
Ok(())
}
```
The macro checks template validity at compile time and generates optimized code.
## License
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or [MIT License](LICENSE-MIT) at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.