K3 Wasm Rust SDK
Getting started
k3-wasm-sdk = { version = "0.1.15" } k3-wasm-macros = { version = "0.1.10" }// your other code here... k3_wasm_macros::init!();#[k3_wasm_macros::http_handler] pub fn get(_req: Request<Vec<u8>>) -> Response<Vec<u8>> { // your code here... }#[k3_wasm_macros::http_handler("/api/users")] pub fn get(_req: Request<Vec<u8>>) -> Response<Vec<u8>> { // your code here... }
Writing handlers
Using the SDK
HTTP
fn get(url: &str) -> Option<Vec<u8>>
fn get(url: &str) -> Option<Vec<u8>>IPFS
fn upload(contents: Vec<u8>) -> String
fn upload(contents: Vec<u8>) -> Stringfn read(cid: &str) -> Vec<u8>
fn read(cid: &str) -> Vec<u8>Key Value Store
fn Db::open_default() -> Db
fn Db::open_default() -> Dbfn Db::get(&self, key: &str) -> Option<String>
fn Db::get(&self, key: &str) -> Option<String>fn Db::set(&mut self, key: &str, value: String)
fn Db::set(&mut self, key: &str, value: String)fn Db::delete(&mut self, key: &str)
fn Db::delete(&mut self, key: &str)Smart contracts
fn call(address: &str, abi: &str, fn_name: &str, params: impl Tokenize) -> String
fn call(address: &str, abi: &str, fn_name: &str, params: impl Tokenize) -> Stringfn query<R: Detokenize>(address: &str, abi: &str, fn_name: &str, params: impl Tokenize) -> R
fn query<R: Detokenize>(address: &str, abi: &str, fn_name: &str, params: impl Tokenize) -> RSpace & Time
fn execute_sql(sql: &str) -> String
fn execute_sql(sql: &str) -> Stringfn execute_create_table(name: &str, types: &str) -> String
fn execute_create_table(name: &str, types: &str) -> StringLast updated