Skip to main content

DynGenerator

Trait DynGenerator 

Source
pub trait DynGenerator: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn capabilities(&self) -> TargetCapabilities;
    fn allows_unsupported(&self) -> bool;
    fn generate(&self, api: &Api, out_dir: &Utf8Path) -> Result<()>;
    fn output_files(&self, api: &Api, out_dir: &Utf8Path) -> Vec<String>;
    fn package(
        &self,
        api: &Api,
        ctx: &PackageContext<'_>,
        out_dir: &Utf8Path,
    ) -> Option<Vec<PackagedFile>>;
    fn config_hash_input(&self) -> Vec<u8> ;
}
Expand description

Object-safe view of a Generator paired with a concrete config.

The orchestrator stores generators as &dyn DynGenerator so it can hold a heterogeneous set of targets whose Config types differ. ConfiguredGenerator is the canonical adapter.

Required Methods§

Source

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

The target’s stable short name. Mirrors Generator::name.

Source

fn capabilities(&self) -> TargetCapabilities

The gated features the target implements. Mirrors Generator::capabilities.

Source

fn allows_unsupported(&self) -> bool

See Generator::allows_unsupported, evaluated against the bound config.

Source

fn generate(&self, api: &Api, out_dir: &Utf8Path) -> Result<()>

Render the bindings under out_dir, using the bound config. Mirrors Generator::generate.

§Errors

Returns an error if the underlying Generator::generate fails to render or write its output.

Source

fn output_files(&self, api: &Api, out_dir: &Utf8Path) -> Vec<String>

The files generate would write. Mirrors Generator::output_files.

Source

fn package( &self, api: &Api, ctx: &PackageContext<'_>, out_dir: &Utf8Path, ) -> Option<Vec<PackagedFile>>

Assemble the distributable package for this target, using the bound config. Mirrors Generator::package; returns None when the target does not support packaging.

Source

fn config_hash_input(&self) -> Vec<u8>

Canonical-JSON encoding of the bound config, fed into the cache hash so a config-only change invalidates the entry.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§