Path: blob/main/crates/misc/component-async-tests/wit/test.wit
3063 views
package local:local;
interface baz {
foo: async func(s: string) -> string;
}
world round-trip {
import baz;
export baz;
}
interface many {
record stuff {
a: list<s32>,
b: bool,
c: u64
}
foo: async func(a: string,
b: u32,
c: list<u8>,
d: tuple<u64, u64>,
e: stuff,
f: option<stuff>,
g: result<stuff>)
-> tuple<string,
u32,
list<u8>,
tuple<u64, u64>,
stuff,
option<stuff>,
result<stuff>>;
}
world round-trip-many {
import many;
export many;
}
world round-trip-direct {
import foo: async func(s: string) -> string;
export foo: async func(s: string) -> string;
}
interface ready {
resource thing {
constructor();
set-ready: func(ready: bool);
when-ready: async func();
}
}
interface continue {
set-continue: func(continue: bool);
get-continue: func() -> bool;
}
interface run {
run: async func();
}
interface backpressure {
set-backpressure: func(enabled: bool);
inc-backpressure: func();
dec-backpressure: func();
}
interface transmit {
variant control {
read-stream(string),
read-stream-zero,
read-future(string),
write-stream(string),
write-stream-zero,
write-future(string),
}
exchange: async func(control: stream<control>,
caller-stream: stream<string>,
caller-future1: future<string>,
caller-future2: future<string>) -> tuple<stream<string>, future<string>, future<string>>;
}
interface post-return {
foo: async func(s: string) -> string;
get-post-return-value: func() -> string;
}
interface borrowing-types {
resource x {
constructor();
foo: func();
}
}
interface borrowing {
use borrowing-types.{x};
foo: async func(x: borrow<x>, misbehave: bool);
}
interface run-bool {
run: async func(v: bool);
}
interface run-result {
run-fail: async func() -> result<_, error-context>;
run-pass: async func() -> result<_, error-context>;
}
interface run-stream {
produce-then-error: func(times: u32) -> stream;
}
interface run-future {
produce-then-error: func() -> future;
}
interface unit-stream {
run: async func(count: u32) -> stream;
}
interface resource-stream {
resource x {
foo: func();
}
foo: async func(count: u32) -> stream<x>;
}
interface closed {
read-stream: async func(rx: stream<u8>, expected: list<u8>);
read-future: async func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
read-future-post-return: async func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
}
interface sleep {
sleep-millis: async func(time-in-millis: u64);
}
interface sleep-with-options {
use cancel.{mode};
variant on-cancel {
task-return,
task-cancel
}
sleep-millis: async func(time-in-millis: u64, on-cancel: on-cancel, on-cancel-delay-millis: u64, synchronous-delay: bool, mode: mode);
}
interface cancel {
variant mode {
normal,
trap-cancel-guest-after-start-cancelled,
trap-cancel-guest-after-return-cancelled,
trap-cancel-guest-after-return,
trap-cancel-host-after-return-cancelled,
trap-cancel-host-after-return,
leak-task-after-cancel,
}
run: async func(mode: mode, cancel-delay-millis: u64);
}
interface intertask {
foo: func(fut: future);
}
interface readiness {
start: async func(s: stream<u8>, expected: list<u8>) -> tuple<stream<u8>, list<u8>>;
}
interface synchronous-transmit {
start: async func(s: stream<u8>, s-expected: list<u8>, f: future<u8>, f-expected: u8) -> tuple<stream<u8>, list<u8>, future<u8>, u8>;
}
interface sleep-post-return {
run: async func(sleep-time-millis: u64);
}
interface closed-stream {
get: func() -> stream<u8>;
}
interface short-reads {
resource thing {
constructor(s: string);
get: async func() -> string;
}
short-reads: async func(s: stream<thing>) -> stream<thing>;
}
world yield-caller {
import continue;
import ready;
import run;
export run;
}
world yield-callee {
import continue;
export run;
}
world yield-host {
import continue;
import ready;
export run;
}
world poll {
import ready;
export run;
}
world backpressure-caller {
import backpressure;
import run;
export run;
}
world backpressure-callee {
export backpressure;
export run;
}
world transmit-caller {
import transmit;
export run;
}
world transmit-callee {
export transmit;
}
world post-return-caller {
import post-return;
export run;
}
world post-return-callee {
export post-return;
}
world borrowing-caller {
import borrowing;
export run-bool;
}
world borrowing-callee {
export borrowing;
export run-bool;
}
world borrowing-host {
import borrowing-types;
export run-bool;
}
world error-context-usage {
export run;
}
world error-context-callee {
export run-result;
export run;
}
world error-context-caller {
import run-result;
export run;
}
world error-context-stream-callee {
export run-stream;
export run;
}
world error-context-stream-caller {
import run-stream;
export run;
}
world error-context-future-callee {
export run-future;
export run;
}
world error-context-future-caller {
import run-future;
export run;
}
world unit-stream-caller {
import unit-stream;
export run;
}
world unit-stream-callee {
export unit-stream;
}
world read-resource-stream {
import resource-stream;
export run;
}
world closed-streams {
export closed;
}
world sleep-host {
import sleep;
}
world cancel-caller {
import backpressure;
import sleep;
import sleep-with-options;
export cancel;
}
world cancel-callee {
import sleep;
export backpressure;
export sleep;
export sleep-with-options;
}
world cancel-host {
export cancel;
}
world intertask-communication {
import intertask;
export run;
}
world readiness-guest {
export readiness;
}
world synchronous-transmit-guest {
export synchronous-transmit;
}
world sleep-post-return-callee {
import sleep;
export sleep-post-return;
}
world sleep-post-return-caller {
import sleep;
import sleep-post-return;
export sleep-post-return;
}
world closed-stream-guest {
export closed-stream;
}
world short-reads-guest {
export short-reads;
}