MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / push_

Method push_

crates/wasmtime/src/runtime/component/resource_table.rs:215–231  ·  view source on GitHub ↗

Push a new entry into the table, returning its handle. This will prefer to use free entries if they exist, falling back on pushing new entries onto the end of the table.

(&mut self, e: TableEntry)

Source from the content-addressed store, hash-verified

213 /// Push a new entry into the table, returning its handle. This will prefer to use free entries
214 /// if they exist, falling back on pushing new entries onto the end of the table.
215 fn push_(&mut self, e: TableEntry) -> Result<u32, ResourceTableError> {
216 if let Some(free) = self.pop_free_list() {
217 self.entries[free] = Entry::Occupied { entry: e };
218 Ok(free.try_into().unwrap())
219 } else {
220 if self.entries.len() >= self.max_capacity {
221 return Err(ResourceTableError::Full);
222 }
223 let ix = self
224 .entries
225 .len()
226 .try_into()
227 .map_err(|_| ResourceTableError::Full)?;
228 self.entries.push(Entry::Occupied { entry: e });
229 Ok(ix)
230 }
231 }
232
233 fn occupied(&self, key: u32) -> Result<&TableEntry, ResourceTableError> {
234 self.entries

Callers 2

pushMethod · 0.80
push_childMethod · 0.80

Calls 6

OkFunction · 0.85
pop_free_listMethod · 0.80
unwrapMethod · 0.45
try_intoMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected