pub enum HostContext {
None,
Unresolved,
WithRules(Arc<Vec<PathMappingRule>>),
}Expand description
Host-context state available to expression evaluation.
Host-context functions (today: apply_path_mapping) need host-supplied
state that the evaluator has no knowledge of. This enum expresses the
three possible states of host availability in a single type, replacing
the previous split between FunctionLibrary::with_host_context and
FunctionLibrary::with_unresolved_host_context.
Variants§
None
No host-context functions are registered. Default.
Unresolved
Host-context function signatures are registered with stub
implementations that return Unresolved(T). Use this at
template-validation time, when real host state is not yet
available but signatures must be known for type checking.
WithRules(Arc<Vec<PathMappingRule>>)
Host-context functions are registered with implementations that use the supplied path mapping rules. Use this at runtime.
Rules are shared via Arc so cloning a library is cheap.
Implementations§
Source§impl HostContext
impl HostContext
Sourcepub fn with_rules(rules: Vec<PathMappingRule>) -> Self
pub fn with_rules(rules: Vec<PathMappingRule>) -> Self
Convenience constructor: take ownership of a Vec<PathMappingRule>
and wrap it in an Arc.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether this host context registers any host-context functions.
Sourcepub fn is_unresolved(&self) -> bool
pub fn is_unresolved(&self) -> bool
Whether this host context uses unresolved stub implementations.
Trait Implementations§
Source§impl Clone for HostContext
impl Clone for HostContext
Source§fn clone(&self) -> HostContext
fn clone(&self) -> HostContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HostContext
impl Debug for HostContext
Source§impl Default for HostContext
impl Default for HostContext
Source§fn default() -> HostContext
fn default() -> HostContext
Auto Trait Implementations§
impl Freeze for HostContext
impl RefUnwindSafe for HostContext
impl Send for HostContext
impl Sync for HostContext
impl Unpin for HostContext
impl UnsafeUnpin for HostContext
impl UnwindSafe for HostContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more