Crates.io | hydrus-ptr-client |
lib.rs | hydrus-ptr-client |
version | 0.1.0 |
source | src |
created_at | 2022-03-08 10:14:57.887765 |
updated_at | 2022-03-08 10:14:57.887765 |
description | A http client for the hydrus ptr |
homepage | |
repository | https://github.com/Trivernis/hydrus-ptr-client |
max_upload_size | |
id | 546187 |
size | 54,837 |
A rust http client for the hydrus PTR. Completeness is not guaranteed.
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