Skip to content

Commit 6781ae2

Browse files
authored
Merge pull request #17 from rvolosatovs/feat/wasip3
feat(p3): add `client` interface
2 parents 9884b6c + 52e5f81 commit 6781ae2

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

wit-0.3.0-draft/client.wit

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
interface client {
2+
use types.{error};
3+
4+
resource connector {
5+
constructor();
6+
7+
/// Set up the encryption stream transform.
8+
/// This takes an unprotected `cleartext` application data stream and
9+
/// returns an encrypted data stream, ready to be sent out over the network.
10+
/// Closing the `cleartext` stream will cause a `close_notify` packet to be emitted on the returned output stream.
11+
send: func(cleartext: stream<u8>) -> tuple<stream<u8>, future<result<_, error>>>;
12+
13+
/// Set up the decryption stream transform.
14+
/// This takes an encrypted data stream, as received via e.g. the network,
15+
/// and returns a decrypted application data stream.
16+
receive: func(ciphertext: stream<u8>) -> tuple<stream<u8>, future<result<_, error>>>;
17+
18+
/// Perform the handshake.
19+
/// The `send` & `receive` streams must be set up before calling this method.
20+
connect: static async func(this: connector, server-name: string) -> result<_, error>;
21+
}
22+
}

wit-0.3.0-draft/types.wit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface types {
2+
resource error {
3+
to-debug-string: func() -> string;
4+
}
5+
}

wit-0.3.0-draft/world.wit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package wasi:tls@0.3.0-draft;
2+
3+
world imports {
4+
import client;
5+
import types;
6+
}

0 commit comments

Comments
 (0)