pub fn store<T, const BUFFER_LENGTH: usize>(payload: T)where
T: Serialize,Expand description
Store a payload to disk
The payload must implement Serialize, and it is serialized using
serde and postcard crates.
§Example
use serde::Serialize;
use wasm4fun_storage::store;
#[derive(Default, Serialize)]
struct SomeStruct {
field: u8,
other_field: f32,
}
let payload: SomeStruct = Default::default();
const BUFFER_LENGTH: usize = 8;
store::<SomeStruct, BUFFER_LENGTH>(payload);§Panics
This function panics if the serialized data is larger than
BUFFER_LENGTH bytes.
§Note
Regardless of the value of BUFFER_LENGTH, WASM-4 only supports storage
for up to 1024 bytes.