1 use {
2     crate::{
3         store::StoreInner,
4         vm::{component::ComponentInstance, VMFuncRef, VMMemoryDefinition},
5         AsContextMut, ValRaw,
6     },
7     anyhow::Result,
8     futures::{stream::FuturesUnordered, FutureExt},
9     std::{boxed::Box, future::Future, mem::MaybeUninit, pin::Pin},
10     wasmtime_environ::component::{
11         RuntimeComponentInstanceIndex, TypeComponentLocalErrorContextTableIndex,
12         TypeFutureTableIndex, TypeStreamTableIndex, TypeTupleIndex,
13     },
14 };
15 
16 pub use futures_and_streams::{ErrorContext, FutureReader, StreamReader};
17 
18 mod futures_and_streams;
19 
20 /// Represents the result of a concurrent operation.
21 ///
22 /// This is similar to a [`std::future::Future`] except that it represents an
23 /// operation which requires exclusive access to a store in order to make
24 /// progress -- without monopolizing that store for the lifetime of the
25 /// operation.
26 pub struct Promise<T>(Pin<Box<dyn Future<Output = T> + Send + Sync + 'static>>);
27 
28 impl<T: 'static> Promise<T> {
29     /// Map the result of this `Promise` from one value to another.
30     pub fn map<U>(self, fun: impl FnOnce(T) -> U + Send + Sync + 'static) -> Promise<U> {
31         Promise(Box::pin(self.0.map(fun)))
32     }
33 
34     /// Convert this `Promise` to a future which may be `await`ed for its
35     /// result.
36     ///
37     /// The returned future will require exclusive use of the store until it
38     /// completes.  If you need to await more than one `Promise` concurrently,
39     /// use [`PromisesUnordered`].
40     pub async fn get<U: Send>(self, store: impl AsContextMut<Data = U>) -> Result<T> {
41         _ = store;
42         todo!()
43     }
44 
45     /// Convert this `Promise` to a future which may be `await`ed for its
46     /// result.
47     ///
48     /// Unlike [`Self::get`], this does _not_ take a store parameter, meaning
49     /// the returned future will not make progress until and unless the event
50     /// loop for the store it came from is polled.  Thus, this method should
51     /// only be used from within host functions and not from top-level embedder
52     /// code.
53     pub fn into_future(self) -> Pin<Box<dyn Future<Output = T> + Send + Sync + 'static>> {
54         self.0
55     }
56 }
57 
58 /// Represents a collection of zero or more concurrent operations.
59 ///
60 /// Similar to [`futures::stream::FuturesUnordered`], this type supports
61 /// `await`ing more than one [`Promise`]s concurrently.
62 pub struct PromisesUnordered<T>(
63     FuturesUnordered<Pin<Box<dyn Future<Output = T> + Send + Sync + 'static>>>,
64 );
65 
66 impl<T: 'static> PromisesUnordered<T> {
67     /// Create a new `PromisesUnordered` with no entries.
68     pub fn new() -> Self {
69         Self(FuturesUnordered::new())
70     }
71 
72     /// Add the specified [`Promise`] to this collection.
73     pub fn push(&mut self, promise: Promise<T>) {
74         self.0.push(promise.0)
75     }
76 
77     /// Get the next result from this collection, if any.
78     pub async fn next<U: Send>(&mut self, store: impl AsContextMut<Data = U>) -> Result<Option<T>> {
79         _ = store;
80         todo!()
81     }
82 }
83 
84 /// Trait representing component model ABI async intrinsics and fused adapter
85 /// helper functions.
86 pub unsafe trait VMComponentAsyncStore {
87     /// The `backpressure.set` intrinsic.
88     fn backpressure_set(
89         &mut self,
90         caller_instance: RuntimeComponentInstanceIndex,
91         enabled: u32,
92     ) -> Result<()>;
93 
94     /// The `task.return` intrinsic.
95     fn task_return(
96         &mut self,
97         instance: &mut ComponentInstance,
98         ty: TypeTupleIndex,
99         storage: *mut ValRaw,
100         storage_len: usize,
101     ) -> Result<()>;
102 
103     /// The `waitable-set.new` intrinsic.
104     fn waitable_set_new(
105         &mut self,
106         instance: &mut ComponentInstance,
107         caller_instance: RuntimeComponentInstanceIndex,
108     ) -> Result<u32>;
109 
110     /// The `waitable-set.wait` intrinsic.
111     fn waitable_set_wait(
112         &mut self,
113         instance: &mut ComponentInstance,
114         caller_instance: RuntimeComponentInstanceIndex,
115         set: u32,
116         async_: bool,
117         memory: *mut VMMemoryDefinition,
118         payload: u32,
119     ) -> Result<u32>;
120 
121     /// The `waitable-set.poll` intrinsic.
122     fn waitable_set_poll(
123         &mut self,
124         instance: &mut ComponentInstance,
125         caller_instance: RuntimeComponentInstanceIndex,
126         set: u32,
127         async_: bool,
128         memory: *mut VMMemoryDefinition,
129         payload: u32,
130     ) -> Result<u32>;
131 
132     /// The `waitable-set.drop` intrinsic.
133     fn waitable_set_drop(
134         &mut self,
135         instance: &mut ComponentInstance,
136         caller_instance: RuntimeComponentInstanceIndex,
137         set: u32,
138     ) -> Result<()>;
139 
140     /// The `waitable.join` intrinsic.
141     fn waitable_join(
142         &mut self,
143         instance: &mut ComponentInstance,
144         caller_instance: RuntimeComponentInstanceIndex,
145         set: u32,
146         waitable: u32,
147     ) -> Result<()>;
148 
149     /// The `yield` intrinsic.
150     fn yield_(&mut self, instance: &mut ComponentInstance, async_: bool) -> Result<()>;
151 
152     /// The `subtask.drop` intrinsic.
153     fn subtask_drop(
154         &mut self,
155         instance: &mut ComponentInstance,
156         caller_instance: RuntimeComponentInstanceIndex,
157         task_id: u32,
158     ) -> Result<()>;
159 
160     /// A helper function for fused adapter modules involving calls where the
161     /// caller is sync-lowered but the callee is async-lifted.
162     fn sync_enter(
163         &mut self,
164         start: *mut VMFuncRef,
165         return_: *mut VMFuncRef,
166         caller_instance: RuntimeComponentInstanceIndex,
167         task_return_type: TypeTupleIndex,
168         result_count: u32,
169         storage: *mut ValRaw,
170         storage_len: usize,
171     ) -> Result<()>;
172 
173     /// A helper function for fused adapter modules involving calls where the
174     /// caller is sync-lowered but the callee is async-lifted.
175     fn sync_exit(
176         &mut self,
177         instance: &mut ComponentInstance,
178         callback: *mut VMFuncRef,
179         caller_instance: RuntimeComponentInstanceIndex,
180         callee: *mut VMFuncRef,
181         callee_instance: RuntimeComponentInstanceIndex,
182         param_count: u32,
183         storage: *mut MaybeUninit<ValRaw>,
184         storage_len: usize,
185     ) -> Result<()>;
186 
187     /// A helper function for fused adapter modules involving calls where the
188     /// caller is async-lowered.
189     fn async_enter(
190         &mut self,
191         start: *mut VMFuncRef,
192         return_: *mut VMFuncRef,
193         caller_instance: RuntimeComponentInstanceIndex,
194         task_return_type: TypeTupleIndex,
195         params: u32,
196         results: u32,
197     ) -> Result<()>;
198 
199     /// A helper function for fused adapter modules involving calls where the
200     /// caller is async-lowered.
201     fn async_exit(
202         &mut self,
203         instance: &mut ComponentInstance,
204         callback: *mut VMFuncRef,
205         post_return: *mut VMFuncRef,
206         caller_instance: RuntimeComponentInstanceIndex,
207         callee: *mut VMFuncRef,
208         callee_instance: RuntimeComponentInstanceIndex,
209         param_count: u32,
210         result_count: u32,
211         flags: u32,
212     ) -> Result<u32>;
213 
214     /// The `future.new` intrinsic.
215     fn future_new(
216         &mut self,
217         instance: &mut ComponentInstance,
218         ty: TypeFutureTableIndex,
219     ) -> Result<u32>;
220 
221     /// The `future.write` intrinsic.
222     fn future_write(
223         &mut self,
224         instance: &mut ComponentInstance,
225         memory: *mut VMMemoryDefinition,
226         realloc: *mut VMFuncRef,
227         string_encoding: u8,
228         ty: TypeFutureTableIndex,
229         future: u32,
230         address: u32,
231     ) -> Result<u32>;
232 
233     /// The `future.read` intrinsic.
234     fn future_read(
235         &mut self,
236         instance: &mut ComponentInstance,
237         memory: *mut VMMemoryDefinition,
238         realloc: *mut VMFuncRef,
239         string_encoding: u8,
240         ty: TypeFutureTableIndex,
241         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
242         future: u32,
243         address: u32,
244     ) -> Result<u32>;
245 
246     /// The `future.cancel-write` intrinsic.
247     fn future_cancel_write(
248         &mut self,
249         instance: &mut ComponentInstance,
250         ty: TypeFutureTableIndex,
251         async_: bool,
252         writer: u32,
253     ) -> Result<u32>;
254 
255     /// The `future.cancel-read` intrinsic.
256     fn future_cancel_read(
257         &mut self,
258         instance: &mut ComponentInstance,
259         ty: TypeFutureTableIndex,
260         async_: bool,
261         reader: u32,
262     ) -> Result<u32>;
263 
264     /// The `future.close-writable` intrinsic.
265     fn future_close_writable(
266         &mut self,
267         instance: &mut ComponentInstance,
268         ty: TypeFutureTableIndex,
269         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
270         writer: u32,
271         error: u32,
272     ) -> Result<()>;
273 
274     /// The `future.close-readable` intrinsic.
275     fn future_close_readable(
276         &mut self,
277         instance: &mut ComponentInstance,
278         ty: TypeFutureTableIndex,
279         reader: u32,
280         error: u32,
281     ) -> Result<()>;
282 
283     /// The `stream.new` intrinsic.
284     fn stream_new(
285         &mut self,
286         instance: &mut ComponentInstance,
287         ty: TypeStreamTableIndex,
288     ) -> Result<u32>;
289 
290     /// The `stream.write` intrinsic.
291     fn stream_write(
292         &mut self,
293         instance: &mut ComponentInstance,
294         memory: *mut VMMemoryDefinition,
295         realloc: *mut VMFuncRef,
296         string_encoding: u8,
297         ty: TypeStreamTableIndex,
298         stream: u32,
299         address: u32,
300         count: u32,
301     ) -> Result<u32>;
302 
303     /// The `stream.read` intrinsic.
304     fn stream_read(
305         &mut self,
306         instance: &mut ComponentInstance,
307         memory: *mut VMMemoryDefinition,
308         realloc: *mut VMFuncRef,
309         string_encoding: u8,
310         ty: TypeStreamTableIndex,
311         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
312         stream: u32,
313         address: u32,
314         count: u32,
315     ) -> Result<u32>;
316 
317     /// The `stream.cancel-write` intrinsic.
318     fn stream_cancel_write(
319         &mut self,
320         instance: &mut ComponentInstance,
321         ty: TypeStreamTableIndex,
322         async_: bool,
323         writer: u32,
324     ) -> Result<u32>;
325 
326     /// The `stream.cancel-read` intrinsic.
327     fn stream_cancel_read(
328         &mut self,
329         instance: &mut ComponentInstance,
330         ty: TypeStreamTableIndex,
331         async_: bool,
332         reader: u32,
333     ) -> Result<u32>;
334 
335     /// The `stream.close-writable` intrinsic.
336     fn stream_close_writable(
337         &mut self,
338         instance: &mut ComponentInstance,
339         ty: TypeStreamTableIndex,
340         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
341         writer: u32,
342         error: u32,
343     ) -> Result<()>;
344 
345     /// The `stream.close-readable` intrinsic.
346     fn stream_close_readable(
347         &mut self,
348         instance: &mut ComponentInstance,
349         ty: TypeStreamTableIndex,
350         reader: u32,
351         error: u32,
352     ) -> Result<()>;
353 
354     /// The "fast-path" implementation of the `stream.write` intrinsic for
355     /// "flat" (i.e. memcpy-able) payloads.
356     fn flat_stream_write(
357         &mut self,
358         instance: &mut ComponentInstance,
359         memory: *mut VMMemoryDefinition,
360         realloc: *mut VMFuncRef,
361         ty: TypeStreamTableIndex,
362         payload_size: u32,
363         payload_align: u32,
364         stream: u32,
365         address: u32,
366         count: u32,
367     ) -> Result<u32>;
368 
369     /// The "fast-path" implementation of the `stream.read` intrinsic for "flat"
370     /// (i.e. memcpy-able) payloads.
371     fn flat_stream_read(
372         &mut self,
373         instance: &mut ComponentInstance,
374         memory: *mut VMMemoryDefinition,
375         realloc: *mut VMFuncRef,
376         ty: TypeStreamTableIndex,
377         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
378         payload_size: u32,
379         payload_align: u32,
380         stream: u32,
381         address: u32,
382         count: u32,
383     ) -> Result<u32>;
384 
385     /// The `error-context.new` intrinsic.
386     fn error_context_new(
387         &mut self,
388         instance: &mut ComponentInstance,
389         memory: *mut VMMemoryDefinition,
390         realloc: *mut VMFuncRef,
391         string_encoding: u8,
392         ty: TypeComponentLocalErrorContextTableIndex,
393         debug_msg_address: u32,
394         debug_msg_len: u32,
395     ) -> Result<u32>;
396 
397     /// The `error-context.debug-message` intrinsic.
398     fn error_context_debug_message(
399         &mut self,
400         instance: &mut ComponentInstance,
401         memory: *mut VMMemoryDefinition,
402         realloc: *mut VMFuncRef,
403         string_encoding: u8,
404         ty: TypeComponentLocalErrorContextTableIndex,
405         err_ctx_handle: u32,
406         debug_msg_address: u32,
407     ) -> Result<()>;
408 
409     /// The `error-context.drop` intrinsic.
410     fn error_context_drop(
411         &mut self,
412         instance: &mut ComponentInstance,
413         ty: TypeComponentLocalErrorContextTableIndex,
414         err_ctx_handle: u32,
415     ) -> Result<()>;
416 }
417 
418 unsafe impl<T> VMComponentAsyncStore for StoreInner<T> {
419     fn backpressure_set(
420         &mut self,
421         caller_instance: RuntimeComponentInstanceIndex,
422         enabled: u32,
423     ) -> Result<()> {
424         _ = (caller_instance, enabled);
425         todo!()
426     }
427 
428     fn task_return(
429         &mut self,
430         instance: &mut ComponentInstance,
431         ty: TypeTupleIndex,
432         storage: *mut ValRaw,
433         storage_len: usize,
434     ) -> Result<()> {
435         _ = (instance, ty, storage, storage_len);
436         todo!()
437     }
438 
439     fn waitable_set_new(
440         &mut self,
441         instance: &mut ComponentInstance,
442         caller_instance: RuntimeComponentInstanceIndex,
443     ) -> Result<u32> {
444         _ = (instance, caller_instance);
445         todo!();
446     }
447 
448     fn waitable_set_wait(
449         &mut self,
450         instance: &mut ComponentInstance,
451         caller_instance: RuntimeComponentInstanceIndex,
452         set: u32,
453         async_: bool,
454         memory: *mut VMMemoryDefinition,
455         payload: u32,
456     ) -> Result<u32> {
457         _ = (instance, caller_instance, set, async_, memory, payload);
458         todo!();
459     }
460 
461     fn waitable_set_poll(
462         &mut self,
463         instance: &mut ComponentInstance,
464         caller_instance: RuntimeComponentInstanceIndex,
465         set: u32,
466         async_: bool,
467         memory: *mut VMMemoryDefinition,
468         payload: u32,
469     ) -> Result<u32> {
470         _ = (instance, caller_instance, set, async_, memory, payload);
471         todo!();
472     }
473 
474     fn waitable_set_drop(
475         &mut self,
476         instance: &mut ComponentInstance,
477         caller_instance: RuntimeComponentInstanceIndex,
478         set: u32,
479     ) -> Result<()> {
480         _ = (instance, caller_instance, set);
481         todo!();
482     }
483 
484     fn waitable_join(
485         &mut self,
486         instance: &mut ComponentInstance,
487         caller_instance: RuntimeComponentInstanceIndex,
488         set: u32,
489         waitable: u32,
490     ) -> Result<()> {
491         _ = (instance, caller_instance, set, waitable);
492         todo!();
493     }
494 
495     fn yield_(&mut self, instance: &mut ComponentInstance, async_: bool) -> Result<()> {
496         _ = (instance, async_);
497         todo!()
498     }
499 
500     fn subtask_drop(
501         &mut self,
502         instance: &mut ComponentInstance,
503         caller_instance: RuntimeComponentInstanceIndex,
504         task_id: u32,
505     ) -> Result<()> {
506         _ = (instance, caller_instance, task_id);
507         todo!()
508     }
509 
510     fn sync_enter(
511         &mut self,
512         start: *mut VMFuncRef,
513         return_: *mut VMFuncRef,
514         caller_instance: RuntimeComponentInstanceIndex,
515         task_return_type: TypeTupleIndex,
516         result_count: u32,
517         storage: *mut ValRaw,
518         storage_len: usize,
519     ) -> Result<()> {
520         _ = (
521             start,
522             return_,
523             caller_instance,
524             task_return_type,
525             result_count,
526             storage,
527             storage_len,
528         );
529         todo!()
530     }
531 
532     fn sync_exit(
533         &mut self,
534         instance: &mut ComponentInstance,
535         callback: *mut VMFuncRef,
536         caller_instance: RuntimeComponentInstanceIndex,
537         callee: *mut VMFuncRef,
538         callee_instance: RuntimeComponentInstanceIndex,
539         param_count: u32,
540         storage: *mut MaybeUninit<ValRaw>,
541         storage_len: usize,
542     ) -> Result<()> {
543         _ = (
544             instance,
545             callback,
546             caller_instance,
547             callee,
548             callee_instance,
549             param_count,
550             storage,
551             storage_len,
552         );
553         todo!()
554     }
555 
556     fn async_enter(
557         &mut self,
558         start: *mut VMFuncRef,
559         return_: *mut VMFuncRef,
560         caller_instance: RuntimeComponentInstanceIndex,
561         task_return_type: TypeTupleIndex,
562         params: u32,
563         results: u32,
564     ) -> Result<()> {
565         _ = (
566             start,
567             return_,
568             caller_instance,
569             task_return_type,
570             params,
571             results,
572         );
573         todo!()
574     }
575 
576     fn async_exit(
577         &mut self,
578         instance: &mut ComponentInstance,
579         callback: *mut VMFuncRef,
580         post_return: *mut VMFuncRef,
581         caller_instance: RuntimeComponentInstanceIndex,
582         callee: *mut VMFuncRef,
583         callee_instance: RuntimeComponentInstanceIndex,
584         param_count: u32,
585         result_count: u32,
586         flags: u32,
587     ) -> Result<u32> {
588         _ = (
589             instance,
590             callback,
591             post_return,
592             caller_instance,
593             callee,
594             callee_instance,
595             param_count,
596             result_count,
597             flags,
598         );
599         todo!()
600     }
601 
602     fn future_new(
603         &mut self,
604         instance: &mut ComponentInstance,
605         ty: TypeFutureTableIndex,
606     ) -> Result<u32> {
607         _ = (instance, ty);
608         todo!()
609     }
610 
611     fn future_write(
612         &mut self,
613         instance: &mut ComponentInstance,
614         memory: *mut VMMemoryDefinition,
615         realloc: *mut VMFuncRef,
616         string_encoding: u8,
617         ty: TypeFutureTableIndex,
618         future: u32,
619         address: u32,
620     ) -> Result<u32> {
621         _ = (
622             instance,
623             memory,
624             realloc,
625             string_encoding,
626             ty,
627             future,
628             address,
629         );
630         todo!()
631     }
632 
633     fn future_read(
634         &mut self,
635         instance: &mut ComponentInstance,
636         memory: *mut VMMemoryDefinition,
637         realloc: *mut VMFuncRef,
638         string_encoding: u8,
639         ty: TypeFutureTableIndex,
640         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
641         future: u32,
642         address: u32,
643     ) -> Result<u32> {
644         _ = (
645             instance,
646             memory,
647             realloc,
648             string_encoding,
649             ty,
650             err_ctx_ty,
651             future,
652             address,
653         );
654         todo!()
655     }
656 
657     fn future_cancel_write(
658         &mut self,
659         instance: &mut ComponentInstance,
660         ty: TypeFutureTableIndex,
661         async_: bool,
662         writer: u32,
663     ) -> Result<u32> {
664         _ = (instance, ty, async_, writer);
665         todo!()
666     }
667 
668     fn future_cancel_read(
669         &mut self,
670         instance: &mut ComponentInstance,
671         ty: TypeFutureTableIndex,
672         async_: bool,
673         reader: u32,
674     ) -> Result<u32> {
675         _ = (instance, ty, async_, reader);
676         todo!()
677     }
678 
679     fn future_close_writable(
680         &mut self,
681         instance: &mut ComponentInstance,
682         ty: TypeFutureTableIndex,
683         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
684         writer: u32,
685         error: u32,
686     ) -> Result<()> {
687         _ = (instance, ty, err_ctx_ty, writer, error);
688         todo!()
689     }
690 
691     fn future_close_readable(
692         &mut self,
693         instance: &mut ComponentInstance,
694         ty: TypeFutureTableIndex,
695         reader: u32,
696         error: u32,
697     ) -> Result<()> {
698         _ = (instance, ty, reader, error);
699         todo!()
700     }
701 
702     fn stream_new(
703         &mut self,
704         instance: &mut ComponentInstance,
705         ty: TypeStreamTableIndex,
706     ) -> Result<u32> {
707         _ = (instance, ty);
708         todo!()
709     }
710 
711     fn stream_write(
712         &mut self,
713         instance: &mut ComponentInstance,
714         memory: *mut VMMemoryDefinition,
715         realloc: *mut VMFuncRef,
716         string_encoding: u8,
717         ty: TypeStreamTableIndex,
718         stream: u32,
719         address: u32,
720         count: u32,
721     ) -> Result<u32> {
722         _ = (
723             instance,
724             memory,
725             realloc,
726             string_encoding,
727             ty,
728             stream,
729             address,
730             count,
731         );
732         todo!()
733     }
734 
735     fn stream_read(
736         &mut self,
737         instance: &mut ComponentInstance,
738         memory: *mut VMMemoryDefinition,
739         realloc: *mut VMFuncRef,
740         string_encoding: u8,
741         ty: TypeStreamTableIndex,
742         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
743         stream: u32,
744         address: u32,
745         count: u32,
746     ) -> Result<u32> {
747         _ = (
748             instance,
749             memory,
750             realloc,
751             string_encoding,
752             ty,
753             err_ctx_ty,
754             stream,
755             address,
756             count,
757         );
758         todo!()
759     }
760 
761     fn stream_cancel_write(
762         &mut self,
763         instance: &mut ComponentInstance,
764         ty: TypeStreamTableIndex,
765         async_: bool,
766         writer: u32,
767     ) -> Result<u32> {
768         _ = (instance, ty, async_, writer);
769         todo!()
770     }
771 
772     fn stream_cancel_read(
773         &mut self,
774         instance: &mut ComponentInstance,
775         ty: TypeStreamTableIndex,
776         async_: bool,
777         reader: u32,
778     ) -> Result<u32> {
779         _ = (instance, ty, async_, reader);
780         todo!()
781     }
782 
783     fn stream_close_writable(
784         &mut self,
785         instance: &mut ComponentInstance,
786         ty: TypeStreamTableIndex,
787         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
788         writer: u32,
789         error: u32,
790     ) -> Result<()> {
791         _ = (instance, ty, err_ctx_ty, writer, error);
792         todo!()
793     }
794 
795     fn stream_close_readable(
796         &mut self,
797         instance: &mut ComponentInstance,
798         ty: TypeStreamTableIndex,
799         reader: u32,
800         error: u32,
801     ) -> Result<()> {
802         _ = (instance, ty, reader, error);
803         todo!()
804     }
805 
806     fn flat_stream_write(
807         &mut self,
808         instance: &mut ComponentInstance,
809         memory: *mut VMMemoryDefinition,
810         realloc: *mut VMFuncRef,
811         ty: TypeStreamTableIndex,
812         payload_size: u32,
813         payload_align: u32,
814         stream: u32,
815         address: u32,
816         count: u32,
817     ) -> Result<u32> {
818         _ = (
819             instance,
820             memory,
821             realloc,
822             ty,
823             payload_size,
824             payload_align,
825             stream,
826             address,
827             count,
828         );
829         todo!()
830     }
831 
832     fn flat_stream_read(
833         &mut self,
834         instance: &mut ComponentInstance,
835         memory: *mut VMMemoryDefinition,
836         realloc: *mut VMFuncRef,
837         ty: TypeStreamTableIndex,
838         err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
839         payload_size: u32,
840         payload_align: u32,
841         stream: u32,
842         address: u32,
843         count: u32,
844     ) -> Result<u32> {
845         _ = (
846             instance,
847             memory,
848             realloc,
849             ty,
850             err_ctx_ty,
851             payload_size,
852             payload_align,
853             stream,
854             address,
855             count,
856         );
857         todo!()
858     }
859 
860     fn error_context_new(
861         &mut self,
862         instance: &mut ComponentInstance,
863         memory: *mut VMMemoryDefinition,
864         realloc: *mut VMFuncRef,
865         string_encoding: u8,
866         ty: TypeComponentLocalErrorContextTableIndex,
867         debug_msg_address: u32,
868         debug_msg_len: u32,
869     ) -> Result<u32> {
870         _ = (
871             instance,
872             memory,
873             realloc,
874             string_encoding,
875             ty,
876             debug_msg_address,
877             debug_msg_len,
878         );
879         todo!()
880     }
881 
882     fn error_context_debug_message(
883         &mut self,
884         instance: &mut ComponentInstance,
885         memory: *mut VMMemoryDefinition,
886         realloc: *mut VMFuncRef,
887         string_encoding: u8,
888         ty: TypeComponentLocalErrorContextTableIndex,
889         err_ctx_handle: u32,
890         debug_msg_address: u32,
891     ) -> Result<()> {
892         _ = (
893             instance,
894             memory,
895             realloc,
896             string_encoding,
897             ty,
898             err_ctx_handle,
899             debug_msg_address,
900         );
901         todo!()
902     }
903 
904     fn error_context_drop(
905         &mut self,
906         instance: &mut ComponentInstance,
907         ty: TypeComponentLocalErrorContextTableIndex,
908         err_ctx_handle: u32,
909     ) -> Result<()> {
910         _ = (instance, ty, err_ctx_handle);
911         todo!()
912     }
913 }
914