vtx-sdk
Official Rust SDK for developing VTX Project plugins.
vtx-sdk provides safe, idiomatic Rust bindings for the VTX Host ABI. It abstracts away the complexity of the WebAssembly Component Model (wit-bindgen), allowing you to focus on building powerful video processing logic.
✨ Features
- Type-Safe APIs: Full Rust type support for database queries, HTTP handling, and file I/O.
- Zero Boilerplate: Use the
vtx_sdk::export!macro to generate all necessary Wasm component exports. - Database Integration: Built-in SQLite helpers with automatic JSON serialization/deserialization.
- Helper Utilities:
ResponseBuilderfor fluent HTTP responses.UserBuilderfor easy auth context management.VtxErrorfor unified error handling.
📦 Installation
Add vtx-sdk to your plugin's Cargo.toml:
[]
= "0.1.1"
= { = "1.0", = ["derive"] }
= "1.0"
= "1.0"
[]
= ["cdylib"] # Essential for compiling to Wasm
🚀 Quick Start
Here is a minimal example of a VTX plugin:
use *;
// 1. Define your plugin structure
;
// 2. Export the component world
export!;
// 3. Implement the Plugin trait
🛠️ Build & Deploy
Plugins must be compiled to the wasm32-wasip1 target.
Prerequisites
Building with vtx-cli (Recommended)
The official CLI handles building, stripping, and packaging (.vtx) automatically.
Manual Build
If you are not using the CLI, you can build the raw Wasm file:
Note: Raw Wasm files may need to be adapted using wasm-tools to work with the VTX runtime if not using vtx-cli.
📚 Modules Overview
-
db: Helpers for executing SQL queries and managing database transactions.- Example:
db::query("SELECT * FROM videos")
- Example:
-
http: HTTP request/response types and builders. -
auth: Utilities for parsing headers and constructingUserContext. -
error: TheVtxErrorenum maps internal errors to appropriate HTTP status codes (e.g.,VtxError::Unauthorized-> 401).
📄 License
This project is licensed under the Apache 2.0 License.