Expand description
Template expansion context.
§Examples
- Define your context type.
 - Implement 
Contexttrait (andContext::visitmethod) for the type.- Get variable name by 
Visitor::var_namemethod. - Feed the corresponding value(s) by one of 
Visitor::visit_*methods. 
 - Get variable name by 
 
Note that contexts should return consistent result across multiple visits for
the same variable. In other words, Context::visit should return the same
result for the same Visitor::var_name() during the context is borrowed.
If this condition is violated, the URI template processor can return
invalid result or panic at worst.
use iri_string::template::context::{Context, Visitor, ListVisitor, AssocVisitor};
struct MyContext {
    name: &'static str,
    id: u64,
    tags: &'static [&'static str],
    children: &'static [(&'static str, usize)],
}
impl Context for MyContext {
    fn visit<V: Visitor>(&self, visitor: V) -> V::Result {
        let name = visitor.var_name().as_str();
        match name {
            "name" => visitor.visit_string(self.name),
            "id" => visitor.visit_string(self.id),
            "tags" => visitor.visit_list().visit_items_and_finish(self.tags),
            "children" => visitor
                .visit_assoc()
                .visit_entries_and_finish(self.children.iter().copied()),
            _ => visitor.visit_undefined(),
        }
   }
}Structs§
- VarName
 - Variable name.
 
Enums§
- Visit
Purpose  - A purpose of a visit.
 
Traits§
- Assoc
Visitor  - Associative array visitor.
 - Context
 - A trait for types that can behave as a static URI template expansion context.
 - Dynamic
Context  - A trait for types that can behave as a dynamic (mutable) URI template expansion context.
 - List
Visitor  - List visitor.
 - Visitor
 - Variable visitor.