Skip to content

Borrowing non-resource types #473

Open
@segeljakt

Description

@segeljakt

Currently, resource types can be passed to a wasm component by reference with borrow<...>:

package my-package:my-world;
world my-world {
    export my-interface: interface {
        resource image;

        load-image: func(bytes: list<u8>) -> image;
        resize-image: func(self: borrow<image>, width:u32, height:u32) -> image;
        image-to-bytes: func(self: borrow<image>) -> list<u8>;
    }
}

According to the documentation, it is not possible to pass non-resource types by reference. Are there any plans of adding this feature? I found the repo https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md, but it seems to be archived.

I am using wasm components to implement filters for streaming applications and it would be nice if the filter could take the data by-reference to avoid copying:

package my-package:my-world;
world my-world {
    export my-interface: interface {
        filter: func(data: borrow<list<string>>) -> bool;
    }
}

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