pub struct ManifestBuilder { /* private fields */ }Expand description
Builder for constructing a WasmManifest-compatible JSON string.
Collects metadata from scenario tags, JTBD blocks, and parsed predicates to produce a complete manifest for embedding in generated WASM modules.
§Examples
use converge_tool::codegen::ManifestBuilder;
use converge_tool::gherkin::{ScenarioMeta, ScenarioKind, InvariantClassTag};
let meta = ScenarioMeta {
name: "Brand Safety".to_string(),
kind: Some(ScenarioKind::Invariant),
invariant_class: Some(InvariantClassTag::Structural),
id: Some("brand_safety".to_string()),
provider: None,
is_test: false,
raw_tags: vec![],
};
let json = ManifestBuilder::new()
.from_scenario_meta(&meta)
.build()
.unwrap();
assert!(json.contains("brand_safety"));
assert!(json.contains("Structural"));Implementations§
Source§impl ManifestBuilder
impl ManifestBuilder
Sourcepub fn from_scenario_meta(self, meta: &ScenarioMeta) -> Self
pub fn from_scenario_meta(self, meta: &ScenarioMeta) -> Self
Populate from extracted scenario metadata (tags).
Sets kind, invariant class, and name from the scenario’s parsed tags.
The @id:<value> tag becomes the module name; if absent, the scenario
name is sanitized to a valid identifier.
Sourcepub fn from_jtbd(self, jtbd: &JTBDMetadata) -> Self
pub fn from_jtbd(self, jtbd: &JTBDMetadata) -> Self
Populate JTBD metadata from a parsed JTBD block.
Sourcepub fn from_predicates(self, predicates: &[Predicate]) -> Self
pub fn from_predicates(self, predicates: &[Predicate]) -> Self
Infer dependencies and capabilities from parsed predicates.
Extracts context key references from predicates as dependencies.
Automatically adds ReadContext capability when dependencies exist.
Sourcepub fn with_version(self, version: &str) -> Self
pub fn with_version(self, version: &str) -> Self
Set the module version.
Sourcepub fn with_source_hash(self, hash: &str) -> Self
pub fn with_source_hash(self, hash: &str) -> Self
Set the source hash (SHA-256 of the .truth file content).
Sourcepub fn with_truth_id(self, id: &str) -> Self
pub fn with_truth_id(self, id: &str) -> Self
Set the truth file ID.
Sourcepub fn build(self) -> Result<String, ManifestError>
pub fn build(self) -> Result<String, ManifestError>
Build the manifest JSON string.
§Errors
Returns ManifestError::MissingInvariantClass if kind is Invariant
but no class tag was provided.
Returns ManifestError::MissingDependencies if kind is Agent but
no context key dependencies were found.
Returns ManifestError::MissingName if no name could be determined.