Skip to content

Commit 53e2d25

Browse files
committed
Update wasi-io dep, remove some TODOs that might not happen that way
1 parent 878c09f commit 53e2d25

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

wit/deps/io/streams.wit

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ default interface streams {
3232
/// Read bytes from a stream.
3333
///
3434
/// This function returns a list of bytes containing the data that was
35-
/// read, along with a bool indicating whether the end of the stream
36-
/// was reached. The returned list will contain up to `len` bytes; it
35+
/// read, along with a bool which, when true, indicates that the end of the
36+
/// stream was reached. The returned list will contain up to `len` bytes; it
3737
/// may return fewer than requested, but not more.
3838
///
3939
/// Once a stream has reached the end, subsequent calls to read or
@@ -53,6 +53,16 @@ default interface streams {
5353
len: u64
5454
) -> result<tuple<list<u8>, bool>, stream-error>
5555

56+
/// Read bytes from a stream, with blocking.
57+
///
58+
/// This is similar to `read`, except that it blocks until at least one
59+
/// byte can be read.
60+
blocking-read: func(
61+
this: input-stream,
62+
/// The maximum number of bytes to read
63+
len: u64
64+
) -> result<tuple<list<u8>, bool>, stream-error>
65+
5666
/// Skip bytes from a stream.
5767
///
5868
/// This is similar to the `read` function, but avoids copying the
@@ -71,6 +81,16 @@ default interface streams {
7181
len: u64,
7282
) -> result<tuple<u64, bool>, stream-error>
7383

84+
/// Skip bytes from a stream, with blocking.
85+
///
86+
/// This is similar to `skip`, except that it blocks until at least one
87+
/// byte can be consumed.
88+
blocking-skip: func(
89+
this: input-stream,
90+
/// The maximum number of bytes to skip.
91+
len: u64,
92+
) -> result<tuple<u64, bool>, stream-error>
93+
7494
/// Create a `pollable` which will resolve once either the specified stream
7595
/// has bytes available to read or the other end of the stream has been
7696
/// closed.
@@ -109,6 +129,16 @@ default interface streams {
109129
buf: list<u8>
110130
) -> result<u64, stream-error>
111131

132+
/// Write bytes to a stream, with blocking.
133+
///
134+
/// This is similar to `write`, except that it blocks until at least one
135+
/// byte can be written.
136+
blocking-write: func(
137+
this: output-stream,
138+
/// Data to write
139+
buf: list<u8>
140+
) -> result<u64, stream-error>
141+
112142
/// Write multiple zero bytes to a stream.
113143
///
114144
/// This function returns a `u64` indicating the number of zero bytes
@@ -119,6 +149,16 @@ default interface streams {
119149
len: u64
120150
) -> result<u64, stream-error>
121151

152+
/// Write multiple zero bytes to a stream, with blocking.
153+
///
154+
/// This is similar to `write-zeroes`, except that it blocks until at least
155+
/// one byte can be written.
156+
blocking-write-zeroes: func(
157+
this: output-stream,
158+
/// The number of zero bytes to write
159+
len: u64
160+
) -> result<u64, stream-error>
161+
122162
/// Read from one stream and write to another.
123163
///
124164
/// This function returns the number of bytes transferred; it may be less
@@ -134,6 +174,18 @@ default interface streams {
134174
len: u64,
135175
) -> result<tuple<u64, bool>, stream-error>
136176

177+
/// Read from one stream and write to another, with blocking.
178+
///
179+
/// This is similar to `splice`, except that it blocks until at least
180+
/// one byte can be read.
181+
blocking-splice: func(
182+
this: output-stream,
183+
/// The stream to read from
184+
src: input-stream,
185+
/// The number of bytes to splice
186+
len: u64,
187+
) -> result<tuple<u64, bool>, stream-error>
188+
137189
/// Forward the entire contents of an input stream to an output stream.
138190
///
139191
/// This function repeatedly reads from the input stream and writes

wit/proxy.wit

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,10 @@ default world proxy {
1212
// log to a developer-facing console (e.g., via `console.log()`).
1313
import console: logging.handler
1414

15-
// TODO: Once the underlying Wit template machinery is implemented, add:
16-
//
17-
// import loggers: interface {
18-
// *: logging.handler
19-
// }
20-
//
21-
// which will allow a component to import any number of non-default logging
22-
// backends that different categories of log messages can be sent to.
23-
24-
// TODO: add `import metrics: metrics.counters`
25-
2615
// This is the default handler to use when user code simply wants to make an
27-
// HTTP request (e.g., via `fetch()`) but doesn't otherwise specify a
28-
// particular handler.
16+
// HTTP request (e.g., via `fetch()`).
2917
import default-outgoing-HTTP: pkg.outgoing-handler
3018

31-
// TODO: Once the underlying Wit template machinery is implemented, add:
32-
//
33-
// import upstreams: interface {
34-
// *: pkg.outgoing-handler
35-
// }
36-
//
37-
// which will allow a component to import any number of non-default backends
38-
// that HTTP requests can be dispatched to.
39-
4019
// The host delivers incoming HTTP requests to a component by calling the
4120
// `handle` function of this exported interface. A host may arbitrarily reuse
4221
// or not reuse component instance when delivering incoming HTTP requests and

0 commit comments

Comments
 (0)