pub struct Templated { /* private fields */ }Expand description
A plugin function’s config: the fields its manifest declared, compiled by
their kinds. The fields come from the CompileCx’s runtime fields.
A call reads them by name with Templated::get, or all at once with
Templated::resolved. Its primary output is the only Output field the
manifest declares, or, of several, the one marked
primary.
Implementations§
Source§impl Templated
impl Templated
Sourcepub fn get<'s>(
&'s self,
ctx: &Ctx<'_>,
name: &str,
) -> Result<Option<Cow<'s, OwnedDataValue>>>
pub fn get<'s>( &'s self, ctx: &Ctx<'_>, name: &str, ) -> Result<Option<Cow<'s, OwnedDataValue>>>
The field name’s value for this call: a literal, and an expression
that folded to a constant, lent from the config; an expression
evaluated, a document rendered, and an output’s or a path’s
destination as a string, owned. None for a field with no value (an
optional one the input left unset, with no default), and for a name
no field has.
§Errors
Ctx::eval’s, for an expression, a path or an output.
Sourcepub fn resolved(&self, ctx: &Ctx<'_>) -> Result<OwnedDataValue>
pub fn resolved(&self, ctx: &Ctx<'_>) -> Result<OwnedDataValue>
Every field with a value, set by the input or by its default, each as
Self::get gives it, as an object in declaration order (an
optional field left unset is absent): what a derived config with the
same fields resolves to (FunctionConfig::resolve, on the same
per-field code). Secrets are read, as the call reads them.
§Errors
The first field’s that fails, as Self::get’s.
Trait Implementations§
Source§impl ConfigField for Templated
impl ConfigField for Templated
Source§fn compile(raw: &Value, cx: &mut CompileCx<'_>) -> Option<Self>
fn compile(raw: &Value, cx: &mut CompileCx<'_>) -> Option<Self>
raw; None after recording at least one issue.Source§fn resolve(&self, r: &mut dyn Resolver) -> Result<Option<OwnedDataValue>>
fn resolve(&self, r: &mut dyn Resolver) -> Result<Option<OwnedDataValue>>
r, or None when
it has none (an Option the input left unset, with no default). The
value sits where Self::visit reports the field’s expressions: a
list’s elements at their indices, a map’s values at their keys, and
an element left unset is null, keeping its place. Read moreSource§const NULL_IS_VALUE: bool = false
const NULL_IS_VALUE: bool = false
null is one of the type’s values. When it is not, an explicit
null in an Option<Self> field means None.Source§const IS_OUTPUT: bool = false
const IS_OUTPUT: bool = false
false unless the type is Output or an
Option of one. The derive reads a field typed Output or marked
#[output] as an output and asserts that this is true, so a type
that merely shares the name is refused at compile time.Source§impl FunctionConfig for Templated
impl FunctionConfig for Templated
Source§fn resolve(&self, r: &mut dyn Resolver) -> Result<OwnedDataValue>
fn resolve(&self, r: &mut dyn Resolver) -> Result<OwnedDataValue>
Templated::resolved, through r.
Source§const TEMPLATED: bool = true
const TEMPLATED: bool = true
Templated, whose fields are
declared by the call’s input rather than by a struct: the registry
checks its spec against that, and the erasure walks its primary
output by its own rule.Source§fn compile(input: &Value, cx: &mut CompileCx<'_>) -> Option<Self>
fn compile(input: &Value, cx: &mut CompileCx<'_>) -> Option<Self>
CompileCx’s root. None when any is Rejected.Source§fn visit(&self, v: &mut dyn ExprVisitor)
fn visit(&self, v: &mut dyn ExprVisitor)
Source§fn primary_output(&self) -> Option<&Output>
fn primary_output(&self) -> Option<&Output>
Ctx::emit_default writes
through, and an answering layer answers with: the derive returns the
field marked #[output(primary)], or the only output when there is
one (None for an Option<Output> the input did not set). A
hand-written config has none unless it says so.