Struct uri_template_system_core::Template
source · pub struct Template<'t> { /* private fields */ }Expand description
The Template type is the basis for most simple tasks. Parsing and
expansion are both template functions.
Implementations§
source§impl<'t> Template<'t>
impl<'t> Template<'t>
sourcepub const fn expand<'e>(&'e self, values: &'e Values) -> Expansion<'e, 't>
pub const fn expand<'e>(&'e self, values: &'e Values) -> Expansion<'e, 't>
Creates a new Expansion using the given Values, which may then be
rendered using the to_string function provided by the Display trait.
let template = Template::parse("hello/{name}!").unwrap();
let values = Values::default().add("name", Value::item("world"));
assert_eq!("hello/world!", template.expand(&values).to_string());sourcepub fn parse(raw: &'t str) -> Result<Self, ParseError>
pub fn parse(raw: &'t str) -> Result<Self, ParseError>
Parses a string representing a potential template, and returns a new
template instance if valid. See https://datatracker.ietf.org/doc/html/rfc6570
for the grammar of a valid URI Template. uri-template-system supports
all operators and modifiers up-to and including Level 4.
let template = Template::parse("my/valid/{template}");
assert!(template.is_ok());Trait Implementations§
source§impl<'t> PartialEq<Template<'t>> for Template<'t>
impl<'t> PartialEq<Template<'t>> for Template<'t>
impl<'t> Eq for Template<'t>
impl<'t> StructuralEq for Template<'t>
impl<'t> StructuralPartialEq for Template<'t>
Auto Trait Implementations§
impl<'t> RefUnwindSafe for Template<'t>
impl<'t> Send for Template<'t>
impl<'t> Sync for Template<'t>
impl<'t> Unpin for Template<'t>
impl<'t> UnwindSafe for Template<'t>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more