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

Method get_data

crates/cache/src/lib.rs:161–172  ·  view source on GitHub ↗

Gets cached data if state matches, otherwise calls `compute`. Data is automatically serialized/deserialized with `bincode`.

(&self, state: T, compute: fn(&T) -> Result<U, E>)

Source from the content-addressed store, hash-verified

159 ///
160 /// Data is automatically serialized/deserialized with `bincode`.
161 pub fn get_data<T, U, E>(&self, state: T, compute: fn(&T) -> Result<U, E>) -> Result<U, E>
162 where
163 T: Hash,
164 U: Serialize + for<'a> Deserialize<'a>,
165 {
166 self.get_data_raw(
167 &state,
168 compute,
169 |_state, data| postcard::to_allocvec(data).ok(),
170 |_state, data| postcard::from_bytes(&data).ok(),
171 )
172 }
173
174 /// Gets cached data if state matches, otherwise calls `compute`.
175 ///

Callers 2

get_data_rawMethod · 0.45
TESTFunction · 0.45

Calls 4

get_data_rawMethod · 0.80
readFunction · 0.50
okMethod · 0.45
joinMethod · 0.45

Tested by 1

TESTFunction · 0.36