not really known
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trivernis 9f95e21dd3
Merge branch 'main' of github.com:Trivernis/hydrus-ptr-client
Signed-off-by: trivernis <trivernis@protonmail.com>
2 years ago
.idea Add content update response 2 years ago
src Add Cargo.toml metadata and README 2 years ago
tests Add Cargo.toml metadata and README 2 years ago
.gitignore Add first horrible implementation of hydrus dictionaries 2 years ago
Cargo.toml Merge branch 'main' of github.com:Trivernis/hydrus-ptr-client 2 years ago
LICENSE Initial commit 2 years ago
README.md Add Cargo.toml metadata and README 2 years ago

README.md

Hydrus PTR Client

A rust http client for the hydrus PTR. Completeness is not guaranteed.

Usage

Fetching metadata and retrieving updates

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);
}

Streaming updates

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;
    }
}

License

Apache-2.0