You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-13Lines changed: 19 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,29 +15,35 @@ Supports 1, 2, and 4 bytes-per-sample data (uint8, uint16, uint32).
15
15
16
16
## Wasm Component interface
17
17
18
-
The module is built as a [Wasm Component](https://component-model.bytecodealliance.org/) and exports a `codec` interface defined in a WebAssembly Interface Type ([WIT](https://component-model.bytecodealliance.org/design/wit.html)) file:
18
+
The module is built as a [Wasm Component](https://component-model.bytecodealliance.org/) and exports a `transform` interface defined in a WebAssembly Interface Type ([WIT](https://component-model.bytecodealliance.org/design/wit.html)) file:
The `package` line declares a namespace, name, and version — the Component Model's equivalent of a package identifier. It scopes the interface names so they don't collide with interfaces from other packages, and it's what tooling uses to refer to this component as a dependency.
36
+
Both `encode` and `decode` take a `port-map` — a list of named byte buffers — and return a `port-map` on success or a human-readable error string on failure.
37
+
38
+
This codec expects three input ports:
34
39
35
-
The `world` declares what this component exposes to the outside world. `export codec` means any host that loads this component can call the functions in the `codec` interface.
40
+
-**`bytes`** — the raw pixel data
41
+
-**`bytes_per_sample`** — UTF-8 digit string (`"1"`, `"2"`, or `"4"`)
42
+
-**`width`** — UTF-8 digit string (e.g. `"256"`)
36
43
37
-
Both `encode` and `decode` take a byte array of pixel data and a JSON config string with `bytes_per_sample` and `width` keys, e.g. `{"bytes_per_sample": 2, "width": 256}`. Both also return a WIT [`result`](https://component-model.bytecodealliance.org/design/wit.html#results) — WIT's typed success-or-failure type, similar to Rust's `Result` or a checked exception in other languages. The two type parameters are the success type and the error type:
44
+
It returns one output port:
38
45
39
-
-**`list<u8>`** (success) — WIT's byte array; contains the encoded or decoded bytes
40
-
-**`string`** (failure) — a human-readable error message, e.g. for an invalid or missing config key
46
+
-**`bytes`** — the encoded or decoded pixel data
41
47
42
48
## Prerequisites
43
49
@@ -49,7 +55,7 @@ Both `encode` and `decode` take a byte array of pixel data and a JSON config str
0 commit comments