vtx_protocol/
lib.rs

1use std::path::PathBuf;
2
3pub const WIT_CONTENT: &str = include_str!("../wit/vtx.wit");
4
5pub fn get_wit_path() -> PathBuf {
6    PathBuf::from(env!("CARGO_MANIFEST_DIR"))
7        .join("wit")
8        .join("vtx.wit")
9}
10
11#[cfg(feature = "guest")]
12mod guest_bindings {
13
14    wit_bindgen::generate!({
15        world: "plugin",
16        path: "wit",
17        ownership: Borrowing {
18            duplicate_if_necessary: true
19        }
20    });
21}
22
23#[cfg(feature = "guest")]
24pub mod types {
25    // 导出核心数据结构(如 HttpRequest, HttpResponse, Manifest 等)
26    pub use super::guest_bindings::vtx::api::types::*;
27
28    // 导出 SQL 接口相关的类型(如 DbValue 等)
29    pub use super::guest_bindings::vtx::api::sql;
30
31    // 导出流式 IO 相关的类型
32    pub use super::guest_bindings::vtx::api::stream_io;
33}
34
35#[cfg(feature = "guest")]
36pub mod exports {
37
38    pub use super::guest_bindings::Guest;
39}
40
41#[cfg(feature = "guest")]
42pub use wit_bindgen;