pub struct HackerNewsClient { /* private fields */ }
Expand description
A wrapping HTTP client for Hacker News Firebase API and real-time data. A client instance should only be instantiated once in an application’s lifecycle, seeking to reuse it where possible.
Implementations§
Source§impl HackerNewsClient
impl HackerNewsClient
Sourcepub fn new_with_timeout(timeout: u64) -> Self
pub fn new_with_timeout(timeout: u64) -> Self
Constructs a new client pointing to the latest Hacker News API version with the configured request timeout.
Sourcepub async fn get_item(&self, id: u32) -> HackerNewsResult<HackerNewsItem>
pub async fn get_item(&self, id: u32) -> HackerNewsResult<HackerNewsItem>
Retrieves item information based on the given ID.
Sourcepub async fn get_user(&self, username: &str) -> HackerNewsResult<HackerNewsUser>
pub async fn get_user(&self, username: &str) -> HackerNewsResult<HackerNewsUser>
Retrieves a user from the user endpoint based on the provided username.
Sourcepub async fn get_story(&self, id: u32) -> HackerNewsResult<HackerNewsStory>
pub async fn get_story(&self, id: u32) -> HackerNewsResult<HackerNewsStory>
Retrieves a story from Hacker News, returning errors if the item was not a valid story type.
Sourcepub async fn get_comment(&self, id: u32) -> HackerNewsResult<HackerNewsComment>
pub async fn get_comment(&self, id: u32) -> HackerNewsResult<HackerNewsComment>
Retrieves a story comment from Hacker News, returning errors if the item was not a valid comment type.
Trait Implementations§
Source§impl Debug for HackerNewsClient
impl Debug for HackerNewsClient
Auto Trait Implementations§
impl Freeze for HackerNewsClient
impl !RefUnwindSafe for HackerNewsClient
impl Send for HackerNewsClient
impl Sync for HackerNewsClient
impl Unpin for HackerNewsClient
impl !UnwindSafe for HackerNewsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more