1个不稳定版本

0.2.0 2023年11月23日

#1595 in 编码

MIT许可证

25KB
497

rdsys后端API

rdsys后端API允许一个进程通过rdsys的两个端点之一接收资源。

使用流端点

要测试或接收来自rdsys的resourcediff,可以使用以下示例代码访问rdsys的resource-stream端点

use rdsys_backend::start_stream;
use tokio;

#[tokio::main]
async fn main() {
    let endpoint = String::from("http://127.0.0.1:7100/resource-stream");
    let name = String::from("https");
    let token = String::from("HttpsApiTokenPlaceholder");
    let types = vec![String::from("obfs2"), String::from("scramblesuit")];
    let rx = start_stream(endpoint, name, token, types).await.unwrap();
    for diff in rx {
        println!("Received diff: {:?}", diff);
    }
}

使用静态请求端点

要测试或接收来自rdsys的ResourceState,可以使用以下示例代码访问resources端点

use rdsys_backend::request_resources;
use tokio;

#[tokio::main]
async fn main() {
    let endpoint = String::from("http://127.0.0.1:7100/resources");
    let name = String::from("https");
    let token = String::from("HttpsApiTokenPlaceholder");
    let types = vec![String::from("obfs4"), String::from("scramblesuit")];
    let rx = request_resources(endpoint, name, token, types).await.unwrap();
    println!("Received ResourceState: {:?}", rx);
}

依赖项

~8–23MB
~317K SLoC