Skip to main content

Emitter

Trait Emitter 

Source
pub trait Emitter {
    // Required methods
    fn target(&self) -> Target;
    fn emit(&self, model: &ExportModel) -> Result<ExportArtifacts>;
}
Expand description

Transpiles an ExportModel into the files of a single deployment target.

Implementations live in their own modules: crate::ComposeEmitter, crate::KubernetesEmitter, and crate::HelmEmitter.

§Determinism requirement

Emitters must produce deterministic output. Container environment maps are unordered, so any map-derived output must be sorted by key before it is written - otherwise golden-file tests become flaky.

§Example

use lightshuttle_export::{Emitter, ComposeEmitter, Target};

let emitter = ComposeEmitter;
assert_eq!(emitter.target(), Target::Compose);

Required Methods§

Source

fn target(&self) -> Target

Returns the Target that this emitter produces.

Source

fn emit(&self, model: &ExportModel) -> Result<ExportArtifacts>

Transpiles model into a set of named files for the emitter’s target.

§Errors

Returns crate::ExportError::Unsupported when a resource in model cannot be represented for this target (for example, a locally built image referenced by a Kubernetes manifest).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§