Skip to content

AddMetadata should be able to clear existing fields #2211

Closed
@vigoo

Description

@vigoo

Feature request

I would like to modify wasm_metadata's AddMetadata struct to be able to express clearing some of the existing metadata fields.

Why

The example use case I'm having is that previously I was storing custom name and version in WASM components as part of our component build flow, and by a recent change in cargo-component, it is now storing the crate name and version (from Cargo.toml) in the same metadata fields. I want our build flow to still store our name and version but unfortunately I am also rely on not having version in some cases (actually I'm storing the wit root package name and version - see WebAssembly/component-model#488). So I need to be able to clear the version metadata put there by cargo-component, if there was no version part of the root wit.

Proposal

I made this change in a fork by introducing something like

pub enum AddMetadataField<T: Debug + Clone> {
    Keep,
    Clear,
    Set(T),
}

and using this in place of the AddMetadata struct's Option fields, happy to open a PR if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions