Skip to main content

SourcePlugin

Trait SourcePlugin 

Source
pub trait SourcePlugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn kind(&self) -> &'static str;
    fn config_schema(&self) -> Schema;
    fn build(
        &self,
        name: &SourceName,
        config: &Value,
        secrets: &dyn SecretResolver,
    ) -> Result<Box<dyn TaskSource>, SourceError>;

    // Provided method
    fn document_relative_paths(&self) -> &'static [&'static str] { ... }
}
Expand description

The factory that turns one configuration block into a live TaskSource.

Having the compile-time registry and the subprocess seam be the same shape is the whole reason this is a trait rather than a free function.

Required Methods§

Source

fn kind(&self) -> &'static str

The name a configuration document’s plugin: field names.

Source

fn config_schema(&self) -> Schema

The JSON Schema for this plugin’s own config: block.

Source

fn build( &self, name: &SourceName, config: &Value, secrets: &dyn SecretResolver, ) -> Result<Box<dyn TaskSource>, SourceError>

Build a live source from one configuration block.

name is the configured source’s name, for error messages only — a plugin never learns it for any other purpose.

§Errors

Returns SourceError::Config when config is not valid for this plugin, or SourceError::Auth when a named credential is absent.

Provided Methods§

Source

fn document_relative_paths(&self) -> &'static [&'static str]

The fields of this plugin’s config: block that name a filesystem path, as dotted paths into that block.

A relative value at one of these, supplied by a configuration document, is resolved against the directory holding that document before Self::build sees it; supplied through the environment or a flag it keeps resolving against the process working directory, because there is no document to rebase it on. A plugin is handed values and no origins, so this declaration is the only way it can say which of its own fields that rule reaches.

Defaulted to none, which is what keeps this an addition rather than a break: a plugin whose block holds no path needs no edit, and a caller asks every plugin rather than keeping a table of which ones answer.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§