pub trait Visitor: Sized + Sealed {
type Result;
type ListVisitor: ListVisitor<Result = Self::Result>;
type AssocVisitor: AssocVisitor<Result = Self::Result>;
// Required methods
fn var_name(&self) -> VarName<'_>;
fn purpose(&self) -> VisitPurpose;
fn visit_undefined(self) -> Self::Result;
fn visit_string<T: Display>(self, v: T) -> Self::Result;
fn visit_list(self) -> Self::ListVisitor;
fn visit_assoc(self) -> Self::AssocVisitor;
// Provided methods
fn visit_list_direct<I, T>(self, items: I) -> Self::Result
where I: IntoIterator<Item = T>,
T: Display { ... }
fn visit_assoc_direct<I, K, T>(self, entries: I) -> Self::Result
where I: IntoIterator<Item = (K, T)>,
K: Display,
T: Display { ... }
}Expand description
Variable visitor.
See the module documentation for usage.
Required Associated Types§
Sourcetype ListVisitor: ListVisitor<Result = Self::Result>
type ListVisitor: ListVisitor<Result = Self::Result>
List visitor.
Sourcetype AssocVisitor: AssocVisitor<Result = Self::Result>
type AssocVisitor: AssocVisitor<Result = Self::Result>
Associative array visitor.
Required Methods§
Sourcefn purpose(&self) -> VisitPurpose
fn purpose(&self) -> VisitPurpose
Returns the purpose of the visit.
The template expansion algorithm checks the types for some variables
depending on its usage. To get the usage count correctly, you should
only count visits with VisitPurpose::Expand.
If you need to know whether the variable is accessed and does not
need dynamic context generation or access counts, consider using
UriTemplateStr::variables method to iterate the variables in the
URI template.
Sourcefn visit_undefined(self) -> Self::Result
fn visit_undefined(self) -> Self::Result
Visits an undefined variable, i.e. indicates that the requested variable is unavailable.
Sourcefn visit_string<T: Display>(self, v: T) -> Self::Result
fn visit_string<T: Display>(self, v: T) -> Self::Result
Visits a string variable.
Sourcefn visit_list(self) -> Self::ListVisitor
fn visit_list(self) -> Self::ListVisitor
Visits a list variable.
If all the items are in a single iterable value, you can use
visit_list_direct instead for convenience.
Sourcefn visit_assoc(self) -> Self::AssocVisitor
fn visit_assoc(self) -> Self::AssocVisitor
Visits an associative array variable.
If all the entries are in a single iterable value, you can use
visit_assoc_direct instead for convenience.
Provided Methods§
Sourcefn visit_list_direct<I, T>(self, items: I) -> Self::Resultwhere
I: IntoIterator<Item = T>,
T: Display,
fn visit_list_direct<I, T>(self, items: I) -> Self::Resultwhere
I: IntoIterator<Item = T>,
T: Display,
Visits just a single list and finishes the visit right away.
Sourcefn visit_assoc_direct<I, K, T>(self, entries: I) -> Self::Result
fn visit_assoc_direct<I, K, T>(self, entries: I) -> Self::Result
Visits just a single associative array and finishes the visit right away.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.