@@ -501,13 +501,16 @@ to the output-stream defined in the `wasi-io` interface.
501
501
#### <a name =" incoming_value " >` type incoming-value ` </a >
502
502
` u32 `
503
503
<p >A incoming-value is a wrapper around a value. It provides a way to read the value
504
- from the input-stream defined in the ` wasi-io ` interface.
504
+ from the ` input-stream ` defined in the ` wasi-io ` interface.
505
505
<p >The incoming-value provides two ways to consume the value:</p >
506
506
<ol >
507
507
<li ><a href =" #incoming_value_consume_sync " ><code >incoming-value-consume-sync</code ></a > consumes the value synchronously and returns the
508
- value as a list of bytes .</li >
508
+ value as a < code > list& lt ; u8 & gt ; </ code > .</li >
509
509
<li ><a href =" #incoming_value_consume_async " ><code >incoming-value-consume-async</code ></a > consumes the value asynchronously and returns the
510
- value as an input-stream.</li >
510
+ value as an <a href =" #input_stream " ><code >input-stream</code ></a >.
511
+ In addition, it provides a <a href =" #incoming_value_size " ><code >incoming-value-size</code ></a > function to get the size of the value.
512
+ This is useful when the value is large and the caller wants to allocate a buffer of
513
+ the right size to consume the value.</li >
511
514
</ol >
512
515
<h4 ><a name =" incoming_value_async_body " ><code >type incoming-value-async-body</code ></a ></h4 >
513
516
<p ><a href =" #input_stream " ><a href =" #input_stream " ><code >input-stream</code ></a ></a ></p >
@@ -523,6 +526,8 @@ value as an input-stream.</li>
523
526
<li ><a name =" drop_bucket.bucket " ><a href =" #bucket " ><code >bucket</code ></a ></a >: <a href =" #bucket " ><a href =" #bucket " ><code >bucket</code ></a ></a ></li >
524
527
</ul >
525
528
<h4 ><a name =" open_bucket " ><code >open-bucket: func</code ></a ></h4 >
529
+ <p >Opens a bucket with the given name.</p >
530
+ <p >If any error occurs, including if the bucket does not exist, it returns an <code >Err(error)</code >.</p >
526
531
<h5 >Params</h5 >
527
532
<ul >
528
533
<li ><a name =" open_bucket.name " ><code >name</code ></a >: <code >string</code ></li >
@@ -542,6 +547,8 @@ value as an input-stream.</li>
542
547
<li ><a name =" new_outgoing_value.0 " ></a > <a href =" #outgoing_value " ><a href =" #outgoing_value " ><code >outgoing-value</code ></a ></a ></li >
543
548
</ul >
544
549
<h4 ><a name =" outgoing_value_write_body_async " ><code >outgoing-value-write-body-async: func</code ></a ></h4 >
550
+ <p >Writes the value to the output-stream asynchronously.
551
+ If any other error occurs, it returns an <code >Err(error)</code >.</p >
545
552
<h5 >Params</h5 >
546
553
<ul >
547
554
<li ><a name =" outgoing_value_write_body_async.outgoing_value " ><a href =" #outgoing_value " ><code >outgoing-value</code ></a ></a >: <a href =" #outgoing_value " ><a href =" #outgoing_value " ><code >outgoing-value</code ></a ></a ></li >
@@ -551,6 +558,8 @@ value as an input-stream.</li>
551
558
<li ><a name =" outgoing_value_write_body_async.0 " ></a > result< ; own< ; <a href =" #outgoing_value_body_async " ><a href =" #outgoing_value_body_async " ><code >outgoing-value-body-async</code ></a ></a >> ; , <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ; </li >
552
559
</ul >
553
560
<h4 ><a name =" outgoing_value_write_body_sync " ><code >outgoing-value-write-body-sync: func</code ></a ></h4 >
561
+ <p >Writes the value to the output-stream synchronously.
562
+ If any other error occurs, it returns an <code >Err(error)</code >.</p >
554
563
<h5 >Params</h5 >
555
564
<ul >
556
565
<li ><a name =" outgoing_value_write_body_sync.outgoing_value " ><a href =" #outgoing_value " ><code >outgoing-value</code ></a ></a >: <a href =" #outgoing_value " ><a href =" #outgoing_value " ><code >outgoing-value</code ></a ></a ></li >
@@ -566,6 +575,8 @@ value as an input-stream.</li>
566
575
<li ><a name =" drop_incoming_value.incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a >: <a href =" #incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a ></li >
567
576
</ul >
568
577
<h4 ><a name =" incoming_value_consume_sync " ><code >incoming-value-consume-sync: func</code ></a ></h4 >
578
+ <p >Consumes the value synchronously and returns the value as a list of bytes.
579
+ If any other error occurs, it returns an <code >Err(error)</code >.</p >
569
580
<h5 >Params</h5 >
570
581
<ul >
571
582
<li ><a name =" incoming_value_consume_sync.incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a >: <a href =" #incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a ></li >
@@ -575,6 +586,8 @@ value as an input-stream.</li>
575
586
<li ><a name =" incoming_value_consume_sync.0 " ></a > result< ; <a href =" #incoming_value_sync_body " ><a href =" #incoming_value_sync_body " ><code >incoming-value-sync-body</code ></a ></a >, <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ; </li >
576
587
</ul >
577
588
<h4 ><a name =" incoming_value_consume_async " ><code >incoming-value-consume-async: func</code ></a ></h4 >
589
+ <p >Consumes the value asynchronously and returns the value as an <a href =" #input_stream " ><code >input-stream</code ></a >.
590
+ If any other error occurs, it returns an <code >Err(error)</code >.</p >
578
591
<h5 >Params</h5 >
579
592
<ul >
580
593
<li ><a name =" incoming_value_consume_async.incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a >: <a href =" #incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a ></li >
@@ -583,14 +596,16 @@ value as an input-stream.</li>
583
596
<ul >
584
597
<li ><a name =" incoming_value_consume_async.0 " ></a > result< ; own< ; <a href =" #incoming_value_async_body " ><a href =" #incoming_value_async_body " ><code >incoming-value-async-body</code ></a ></a >> ; , <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ; </li >
585
598
</ul >
586
- <h4 ><a name =" size " ><code >size: func</code ></a ></h4 >
599
+ <h4 ><a name =" incoming_value_size " ><code >incoming-value-size: func</code ></a ></h4 >
600
+ <p >The size of the value in bytes.
601
+ If the size is unknown or unavailable, this function returns an <code >Err(error)</code >.</p >
587
602
<h5 >Params</h5 >
588
603
<ul >
589
- <li ><a name =" size .incoming_value" ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a >: <a href =" #incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a ></li >
604
+ <li ><a name =" incoming_value_size .incoming_value" ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a >: <a href =" #incoming_value " ><a href =" #incoming_value " ><code >incoming-value</code ></a ></a ></li >
590
605
</ul >
591
606
<h5 >Return values</h5 >
592
607
<ul >
593
- <li ><a name =" size .0" ></a > <code >u64</code ></li >
608
+ <li ><a name =" incoming_value_size .0" ></a > result & lt ; <code >u64</code >, < a href = " #error " >< a href = " #error " >< code >error</ code ></ a ></ a > & gt ; </li >
594
609
</ul >
595
610
<h2 ><a name =" wasi:keyvalue_readwrite " >Import interface wasi:keyvalue/readwrite</a ></h2 >
596
611
<p >A keyvalue interface that provides simple read and write operations.</p >
0 commit comments