Docs›qos-sdk›state_get
qos-sdk Reference

qos_sdk::state::get

Retrieves the value for a given key from the Edge Node's Sled database.

#Signature

pub fn get(key: &str) -> Option<Vec<u8>>

#Usage

If the key exists, the host returns the bytes exactly as they were stored. If the key does not exist, None is returned.

src/lib.rs
use qos_sdk::state;

#[no_mangle]
pub extern "C" fn run() -> i32 {
    if let Some(val) = state::get("counter") {
        if val.len() == 1 {
            let count = val[0];
            // ... use count ...
        }
    }
    0
}

💡 TIP

Because WASM memory allocation is cheap, get() allocates a fresh Vec<u8> per call. You don't need to manually size buffers or handle pointers unless using the raw ABI.