Skip to main content

ManifestBuilder

Struct ManifestBuilder 

Source
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

Source

pub fn new() -> Self

Create a new empty manifest builder.

Source

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.

Source

pub fn from_jtbd(self, jtbd: &JTBDMetadata) -> Self

Populate JTBD metadata from a parsed JTBD block.

Source

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.

Source

pub fn with_version(self, version: &str) -> Self

Set the module version.

Source

pub fn with_source_hash(self, hash: &str) -> Self

Set the source hash (SHA-256 of the .truth file content).

Source

pub fn with_truth_id(self, id: &str) -> Self

Set the truth file ID.

Source

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.

Trait Implementations§

Source§

impl Default for ManifestBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more