SDK Reference
qos-sdk Reference
The Q-OS host ABI exposes a minimal set of extern "C" functions that your WASM module can import. There is no separate library to link — the host runtime injects these symbols at instantiation time.
__qos_state_getfn __qos_state_get(key_ptr: *const u8, key_len: u32, out_ptr: *mut u8) -> u32Reads a value from the Sled K/V store by key. Returns the byte length written into out_ptr. Returns 0 if the key does not exist.
Example Usage
rust
fn state_get(key: &str) -> Option<String> {
let key_bytes = key.as_bytes();
let mut buf = vec![0u8; 4096];
let len = unsafe {
__qos_state_get(key_bytes.as_ptr(), key_bytes.len() as u32, buf.as_mut_ptr())
};
if len == 0 { return None; }
String::from_utf8(buf[..len as usize].to_vec()).ok()
}__qos_state_setfn __qos_state_set(key_ptr: *const u8, key_len: u32, val_ptr: *const u8, val_len: u32)Writes a key-value pair to the Sled store. Writes are atomic and immediately durable. The change is broadcast to all WebSocket subscribers as a STATE_MUTATION event.
Example Usage
rust
fn state_set(key: &str, value: &str) {
let k = key.as_bytes();
let v = value.as_bytes();
unsafe {
__qos_state_set(k.as_ptr(), k.len() as u32, v.as_ptr(), v.len() as u32)
};
}More ABI functions — coming soon
__qos_broadcast, __qos_log, __qos_timestamp are on the roadmap.