iri_string::template::context

Trait Visitor

source
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;
}
Expand description

Variable visitor.

See the module documentation for usage.

Required Associated Types§

source

type Result

Result of the visit.

source

type ListVisitor: ListVisitor<Result = Self::Result>

List visitor.

source

type AssocVisitor: AssocVisitor<Result = Self::Result>

Associative array visitor.

Required Methods§

source

fn var_name(&self) -> VarName<'_>

Returns the name of the variable to visit.

source

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.

source

fn visit_undefined(self) -> Self::Result

Visits an undefined variable, i.e. indicates that the requested variable is unavailable.

source

fn visit_string<T: Display>(self, v: T) -> Self::Result

Visits a string variable.

source

fn visit_list(self) -> Self::ListVisitor

Visits a list variable.

source

fn visit_assoc(self) -> Self::AssocVisitor

Visits an associative array variable.

Object Safety§

This trait is not object safe.

Implementors§