#ptr #hydrus #update #metadata

hydrus-ptr-client

hydrus PTR的HTTP客户端

1个不稳定版本

0.1.0 2022年3月8日

#391HTTP客户端

Apache-2.0

40KB
999

Hydrus PTR客户端

Hydrus PTR的Rust HTTP客户端。完整性无法保证。

使用

获取元数据和检索更新

use hydrus_ptr_client::Client;

#[tokio::main]
async fn main() {
    let client = Client::builder().accept_invalid_certs(true).build().unwrap();
    // list of all update files since id = 0
    let metadata = client.get_metadata(0).await.unwrap();
    let first_update_file = metadata.update_hashes().swap_remove(0);
    let update = client.get_update(first_update_file).await.unwrap();
    println!("Got update {:?}", update);
}

流式更新

use hydrus_ptr_client::Client;
use futures_util::StreamExt;

#[tokio::main]
async fn main() {
    let client = Client::builder().accept_invalid_certs(true).build().unwrap();
    // streams all update since id = 0
    let mut update_stream = client.stream_updates(0).await.unwrap();
    
    while let Some(result) = update_stream.next().await {
        match result {
            Ok(update) => println!("We got an update {:?}", update),
            Err(e) => println!("Oh no, an error occurred {}", e),
        }
        break;
    }
}

许可证

Apache-2.0

依赖项

~4–20MB
~288K SLoC