Skip to content

Add support for Serialize, Deserialize, and Default #554

@autodidaddict

Description

@autodidaddict

The structures that we get from Rust when doing wit-bindgen do not have the Default or Serialize or Deserialize derivations on them. This means that as soon as I attempt to marshal one of these data types somewhere without using a wit function call, I have to manually create my own "mirror types" that have the same structure, but with the serialization attributes on them. Then I have to manually implement either From to convert the wit-bindgen type to my type prior to serialization.

I understand that this kind of activity typically shows up in anti-corruption layers and in an ideal world, the "outside" model and the inside (wit-bindgen) model would never overlap. However, if I have a lot of types and I need to marshal those in and out of my components without making bindgen function calls, I'm stuck redefining every type in my wit world.

Can we get this functionality? If it isn't something that you want on by default, it could be added as a flag to the macro like this:

wit_bindgen::generate!({
    path: "../wit",
    world: "bankaccount-aggregate",
    serializers: true
});

Support for the serializers flag could even be hidden behind a feature flag on the wit-bindgen crate.

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