newswrap/lib.rs
1//! [Hacker News](https://news.ycombinator.com/) API bindings for Rust with full async support.
2//!
3//! ```
4//! use newswrap::{client::HackerNewsClient, errors::HackerNewsClientError};
5//!
6//! #[tokio::main]
7//! async fn main() -> Result<(), HackerNewsClientError> {
8//! // Build your client at the start of your application process
9//! let client = HackerNewsClient::new();
10//!
11//! // Call various endpoints with your client instance
12//! let generic_item = client.items.get_item(69).await?;
13//! dbg!(&generic_item);
14//!
15//! // Determine what the item type is
16//! let item_type = generic_item.get_item_type();
17//! dbg!(item_type);
18//!
19//! // Check if the item is job
20//! assert!(generic_item.is_story());
21//!
22//! // Retrieve user information
23//! let user = client.users.get_user("joeymckenzie").await?;
24//! dbg!(user);
25//!
26//! Ok(())
27//! }
28//! ```
29
30#![forbid(unsafe_code, dead_code)]
31#![warn(
32 missing_docs,
33 missing_debug_implementations,
34 missing_copy_implementations,
35 trivial_casts,
36 unused_allocation,
37 trivial_numeric_casts,
38 clippy::single_char_pattern
39)]
40
41pub mod client;
42pub mod errors;
43mod http;
44pub mod items;
45pub mod realtime;
46pub mod users;
47
48/// The ID associated to all Hacker News items and users.
49pub type HackerNewsID = u32;