gp_wasm_interface/
store_data.rs

1use crate::HostState;
2use wasmtime::{Memory, Table};
3
4#[derive(Default)]
5pub struct StoreData {
6	/// This will only be set when we call into the runtime.
7	pub host_state: Option<HostState>,
8	/// This will be always set once the store is initialized.
9	pub memory: Option<Memory>,
10	/// This will be set only if the runtime actually contains a table.
11	pub table: Option<Table>,
12}
13
14impl StoreData {
15	/// Returns a mutable reference to the host state.
16	pub fn host_state_mut(&mut self) -> Option<&mut HostState> {
17		self.host_state.as_mut()
18	}
19
20	/// Returns the host memory.
21	pub fn memory(&self) -> Memory {
22		self.memory.expect("memory is always set; qed")
23	}
24}