pub trait Emitter: Send + Sync {
// Required methods
fn emit_thin(
&self,
ir: &IntermediateRepresentation,
) -> EmitterResult<String>;
fn emit_expanded(
&self,
ir: &IntermediateRepresentation,
) -> EmitterResult<String>;
fn format_name(&self) -> &'static str;
fn file_extension(&self) -> &'static str;
// Provided methods
fn emit(&self, ir: &IntermediateRepresentation) -> EmitterResult<String> { ... }
fn description(&self) -> &'static str { ... }
fn validate(&self, ir: &IntermediateRepresentation) -> EmitterResult<()> { ... }
}Expand description
Trait for CI configuration emitters
Implementations transform the IR into orchestrator-specific configurations. Each emitter is responsible for mapping IR concepts to the target format.
§Pipeline Modes
Emitters must implement both emit_thin and emit_expanded methods:
emit_thin: Single-job workflow with cuenv orchestrationemit_expanded: Multi-job workflow with orchestrator dependencies
The default emit method dispatches based on ir.pipeline.mode.
§Example
use cuenv_ci::emitter::{Emitter, EmitterResult};
use cuenv_ci::ir::IntermediateRepresentation;
struct MyEmitter;
impl Emitter for MyEmitter {
fn emit_thin(&self, ir: &IntermediateRepresentation) -> EmitterResult<String> {
// Generate single-job workflow
Ok("# Thin mode config".to_string())
}
fn emit_expanded(&self, ir: &IntermediateRepresentation) -> EmitterResult<String> {
// Generate multi-job workflow
Ok("# Expanded mode config".to_string())
}
fn format_name(&self) -> &'static str {
"my-ci"
}
fn file_extension(&self) -> &'static str {
"yml"
}
}Required Methods§
Sourcefn emit_thin(&self, ir: &IntermediateRepresentation) -> EmitterResult<String>
fn emit_thin(&self, ir: &IntermediateRepresentation) -> EmitterResult<String>
Emit a thin mode CI configuration.
Thin mode generates a single-job workflow that:
- Runs bootstrap phase steps (e.g., install Nix)
- Runs setup phase steps (e.g., build cuenv)
- Executes
cuenv ci --pipeline <name>for orchestration - Runs success/failure phase steps with conditions
§Arguments
ir- The compiled intermediate representation
§Returns
The generated CI configuration as a string
§Errors
Returns EmitterError if the IR cannot be transformed or serialized
Sourcefn emit_expanded(
&self,
ir: &IntermediateRepresentation,
) -> EmitterResult<String>
fn emit_expanded( &self, ir: &IntermediateRepresentation, ) -> EmitterResult<String>
Emit an expanded mode CI configuration.
Expanded mode generates a multi-job workflow where:
- Each task becomes a separate job
- Task dependencies map to job dependencies (
needs:in GitHub Actions) - Phase tasks are included as steps within each job
§Arguments
ir- The compiled intermediate representation
§Returns
The generated CI configuration as a string
§Errors
Returns EmitterError if the IR cannot be transformed or serialized
Sourcefn format_name(&self) -> &'static str
fn format_name(&self) -> &'static str
Get the format identifier for this emitter
Used for CLI flag matching (e.g., “buildkite”, “gitlab”, “tekton”)
Sourcefn file_extension(&self) -> &'static str
fn file_extension(&self) -> &'static str
Get the file extension for output files
Typically “yml” or “yaml” for most CI systems
Provided Methods§
Sourcefn emit(&self, ir: &IntermediateRepresentation) -> EmitterResult<String>
fn emit(&self, ir: &IntermediateRepresentation) -> EmitterResult<String>
Emit a CI configuration based on the mode in the IR.
This is the primary entry point for emission. It dispatches to
emit_thin or emit_expanded based on ir.pipeline.mode.
§Arguments
ir- The compiled intermediate representation
§Returns
The generated CI configuration as a string
§Errors
Returns EmitterError if the IR cannot be transformed or serialized
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Get a human-readable description of this emitter
Sourcefn validate(&self, ir: &IntermediateRepresentation) -> EmitterResult<()>
fn validate(&self, ir: &IntermediateRepresentation) -> EmitterResult<()>
Validate the IR before emission
Override this to perform emitter-specific validation beyond the standard IR validation.
§Errors
Returns EmitterError::InvalidIR if validation fails