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>;
}
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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Resolver for &Ctx<'_>