MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / start

Method start

crates/guest-rust/src/rt/async_support/subtask.rs:108–129  ·  view source on GitHub ↗
(&mut self, state: Self::Start)

Source from the content-addressed store, hash-verified

106 type Cancel = Result<T::Results, ()>;
107
108 fn start(&mut self, state: Self::Start) -> (u32, Self::InProgress) {
109 unsafe {
110 let (ptr_params, cleanup) = Cleanup::new(self.0.abi_layout());
111 let ptr_results = ptr_params.add(self.0.results_offset());
112 let params_lower = self.0.params_lower(state.params, ptr_params);
113 let packed = self.0.call_import(params_lower, ptr_results);
114 let code = packed & 0xf;
115 let subtask = NonZeroU32::new(packed >> 4).map(|handle| SubtaskHandle { handle });
116 rtdebug!("<import>({ptr_params:?}, {ptr_results:?}) = ({code:#x}, {subtask:#x?})");
117
118 (
119 code,
120 InProgress {
121 params_lower,
122 params_and_results: cleanup,
123 subtask,
124 started: false,
125 _marker: marker::PhantomData,
126 },
127 )
128 }
129 }
130
131 fn start_cancelled(&mut self, _state: Self::Start) -> Self::Cancel {
132 Err(())

Callers 1

poll_completeMethod · 0.45

Calls 3

newFunction · 0.85
mapMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected