Function extism_pdk::var::get

source ·
pub fn get<T: FromBytesOwned>(key: impl AsRef<str>) -> Result<Option<T>, Error>
Expand description

Gets a variable in the plug-in. This variable lives as long as the plug-in is loaded.

§Arguments

  • key - A unique string key to identify the variable

§Examples

// let's assume we have a variable at `"my_var"`
// which is a u32. We can default to 0 first time we fetch it:
let my_var = var::get("my_var")?.unwrap_or(0u32);