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§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
The target’s stable short name. Mirrors Generator::name.
Sourcefn capabilities(&self) -> TargetCapabilities
fn capabilities(&self) -> TargetCapabilities
The gated features the target implements. Mirrors
Generator::capabilities.
Sourcefn allows_unsupported(&self) -> bool
fn allows_unsupported(&self) -> bool
See Generator::allows_unsupported, evaluated against the bound
config.
Sourcefn generate(&self, api: &Api, out_dir: &Utf8Path) -> Result<()>
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.
Sourcefn output_files(&self, api: &Api, out_dir: &Utf8Path) -> Vec<String>
fn output_files(&self, api: &Api, out_dir: &Utf8Path) -> Vec<String>
The files generate would write. Mirrors
Generator::output_files.
Sourcefn package(
&self,
api: &Api,
ctx: &PackageContext<'_>,
out_dir: &Utf8Path,
) -> Option<Vec<PackagedFile>>
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.
Sourcefn config_hash_input(&self) -> Vec<u8> ⓘ
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".