This reference documents the low-level host functions that workflows call from WebAssembly. Most users should use the high-level Rust SDK wrappers instead.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/slunghq/slung/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Workflows execute in a WebAssembly sandbox and communicate with the Slung host through imported functions. These functions use aRegion-based memory protocol for passing non-primitive data.
Memory Protocol
The host and guest exchange data using theRegion struct:
allocate() and deallocate() functions for the host to manage memory:
Host Functions
u_query_live
Guest pointer to a
Region containing UTF-8 filter bytesReturns
Query handle (u64), or 0 on failure.
Usage
u_query_history
Guest pointer to a
Region containing UTF-8 filter bytesReturns
Aggregated value (f64). Returns 0.0 on failure or for valid zero results.
Usage
u_poll_handle
Query handle returned by
u_query_liveReturns
Guest pointer to aRegion containing JSON event data, or 0 if no event is available.
Usage
u_free_handle
Query handle to free
Returns
0 on success, non-zero on failure.
Usage
u_write_event
Guest pointer to a
Region containing UTF-8 timestamp stringGuest pointer to a
Region containing UTF-8 value stringGuest pointer to a
Region containing UTF-8 CSV tagsReturns
0 on success, non-zero on failure.
Usage
u_writeback_ws
Producer connection ID
Guest pointer to a
Region containing data to sendReturns
0 on success, non-zero on failure.
Usage
u_writeback_http
Guest pointer to a
Region containing UTF-8 URLGuest pointer to a
Region containing request bodyHTTP method:
0 = GET, 1 = POST, 2 = PUT, 3 = DELETEReturns
Guest pointer to a responseRegion, or 0 if no response body is available or the request fails.
Usage
Region Utilities
Region::build()
deallocate on this region.
Region::release_buffer()
deallocate to free both the Region and the Vec memory.
Region::consume()
Best Practices
- Use
Region::build()for passing data to the host - Use
Region::consume()for receiving data from the host - Never manually free regions created with
Region::build() - Always free regions returned by host functions
- Check for null/zero pointers before consuming regions
Next Steps
Workflow API Reference
High-level Rust SDK API documentation
Rust Workflow Guide
Building workflows with the Rust SDK