Skip to main content

Templated

Struct Templated 

Source
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

Source

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.

Source

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

Source§

fn compile(raw: &Value, cx: &mut CompileCx<'_>) -> Option<Self>

Compiles raw; None after recording at least one issue.
Source§

fn visit(&self, v: &mut Visit<'_>)

Reports the field’s expressions.
Source§

fn resolve(&self, r: &mut dyn Resolver) -> Result<Option<OwnedDataValue>>

The field’s value for this call, resolved through 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 more
Source§

fn kind() -> FieldKind

What the field is.
Source§

const NULL_IS_VALUE: bool = false

Whether 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

Whether the field is an output: a destination its call writes to. 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§

fn absent() -> Option<Self>

The value when the key is absent and no default is declared. None makes the field required.
Source§

impl Debug for Templated

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FunctionConfig for Templated

Source§

fn resolve(&self, r: &mut dyn Resolver) -> Result<OwnedDataValue>

Templated::resolved, through r.

Source§

const TEMPLATED: bool = true

Whether this is 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>

Every issue in the config, each at its exact path below the CompileCx’s root. None when any is Rejected.
Source§

fn visit(&self, v: &mut dyn ExprVisitor)

Walks the config’s expressions; paths are relative to the config’s root.
Source§

fn fields() -> &'static [FieldSpec]

The config’s fields, for tooling.
Source§

fn primary_output(&self) -> Option<&Output>

The 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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.