Skip to main content

Resolver

Trait Resolver 

Source
pub trait Resolver: Sealed {
    // Required methods
    fn eval(&mut self, expr: &dyn ResolveExpr) -> Result<OwnedDataValue>;
    fn render(&mut self, doc: &Interpolated) -> Result<OwnedDataValue>;

    // Provided method
    fn output_override(&mut self, _out: &Output) -> Option<OutputOverride> { ... }
}
Expand description

What resolving a config needs from a call: an expression evaluated, and a document rendered, each to an owned value, against the context the call sees. A ConfigField calls it from ConfigField::resolve; a call’s context implements it (Ctx, through a shared reference).

Sealed: a host calls it, from its own ConfigField::resolve, and never implements it, so a method can join it without a breaking change.

ⓘ
use dataflow_rs::Result;
use dataflow_rs::datavalue::OwnedDataValue;
use dataflow_rs::expr::{Interpolated, ResolveExpr, Resolver};

struct Mine;

impl Resolver for Mine {
    fn eval(&mut self, _expr: &dyn ResolveExpr) -> Result<OwnedDataValue> {
        Ok(OwnedDataValue::Null)
    }
    fn render(&mut self, _doc: &Interpolated) -> Result<OwnedDataValue> {
        Ok(OwnedDataValue::Null)
    }
}

Required Methods§

Source

fn eval(&mut self, expr: &dyn ResolveExpr) -> Result<OwnedDataValue>

expr evaluated, as an owned value: a number for a u64, i64 or f64 expression, a boolean for a bool one, a string for a String one, a path’s dotted text for a Path one, and the value itself for any other. A folded constant is its value, evaluated never.

§Errors

The evaluation’s: ErrorKind::Budget when the operation ceiling is exceeded, ErrorKind::Eval for any other failure, a result that is not of the expression’s type included.

Source

fn render(&mut self, doc: &Interpolated) -> Result<OwnedDataValue>

doc rendered, as an owned tree: each hole’s value, or its default.

§Errors

None from a call’s context, which is every resolver there is today; the Result leaves room for one that may refuse.

Provided Methods§

Source

fn output_override(&mut self, _out: &Output) -> Option<OutputOverride>

The value out resolves to in place of being evaluated, when this resolution supplies the callee’s primary output: None resolves it as usual, as every resolver does but the two input methods that supply it.

Only the Output a config’s primary_output lends is answered; every other output, a nested one included, is resolved as usual.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Resolver for &Ctx<'_>