hacker-rs

Crates.iohacker-rs
lib.rshacker-rs
version0.1.5
sourcesrc
created_at2023-07-03 23:56:36.32027
updated_at2023-07-06 23:12:57.821135
descriptionHacker News API bindings for rust.
homepagehttps://github.com/joeymckenzie/hacker-rs/
repositoryhttps://github.com/joeymckenzie/hacker-rs/
max_upload_size
id907507
size66,619
Joey McKenzie (JoeyMckenzie)

documentation

https://docs.rs/hacker-rs

README

hacker-rs

Hacker News API bindings for Rust.

use hacker_rs::client::HackerNewsClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Build your client at the start of your application process
    let client = HackerNewsClient::new();

    // Call various endpoints with your client instance
    let first_item = client.get_item(69).await?;
    dbg!(&first_item);

    // Determine what the item type is
    let item_type = first_item.get_item_type();
    dbg!(item_type);

    // Check if the item is job
    assert!(first_item.is_comment());

    // Retrieve user information
    let user = client.get_user("joeymckenzie").await;
    dbg!(user);

    Ok(())
}
Commit count: 62

cargo fmt