the0-sdk (Rust)
Optional SDK for building trading bots on the0 platform.
Note: This SDK is optional. The the0 runtime automatically wraps your bot's output:
- Exit code 0 →
{"status":"success","message":"Bot executed successfully"} - Exit code non-zero →
{"status":"error","message":"Bot execution failed"} - If you output JSON with a
"status"field, it's passed through as-is
Minimal Example (No SDK)
use env;
With SDK (Optional)
The SDK provides convenience methods for parsing config and outputting custom results.
Installation
Add to your Cargo.toml:
[]
= "0.1"
= "1.0" # Required for config access
Or from git:
[]
= { = "https://github.com/alexanderwanyoike/the0", = "sdk/rust" }
Usage
use input;
API Reference
input::parse() -> (String, Value)
Parse bot configuration from environment. Returns (bot_id, config).
input::parse_as_map() -> (String, HashMap<String, Value>)
Parse configuration as a HashMap for easier access.
input::success(message: &str)
Output success result and continue execution.
input::error(message: &str) -> !
Output error result and exit with code 1.
input::result(data: &Value)
Output custom JSON result.
Example Bot
See the Rust Quick Start Guide for a complete example.
Publishing (Maintainers)
This package is published to crates.io.
Prerequisites
-
Login to crates.io:
-
Ensure you have ownership of the crate on crates.io
Publish
# Verify the package
# Publish to crates.io
Version Bump
Update the version in Cargo.toml:
= "0.2.0"
Then publish.
License
Apache-2.0