Struct HnClient

Source
pub struct HnClient { /* private fields */ }
Expand description

The API client.

Implementations§

Source§

impl HnClient

Source

pub fn init() -> Result<Self>

Create a new HnClient instance.

Source

pub fn get_item(&self, id: u32) -> Result<Option<Item>>

Return the item with the specified id.

May return None if item id is invalid.

Source

pub fn get_user(&self, username: &str) -> Result<Option<User>>

Return the user with the specified username.

May return None if username is invalid.

Source

pub fn get_max_item_id(&self) -> Result<u32>

Return the id of the newest item.

To get the 10 latest items, you can decrement the id 10 times.

Source

pub fn get_top_stories(&self) -> Result<Vec<u32>>

Return a list of top story item ids.

Source

pub fn get_new_stories(&self) -> Result<Vec<u32>>

Return a list of new story item ids.

Source

pub fn get_best_stories(&self) -> Result<Vec<u32>>

Return a list of best story item ids.

Source

pub fn get_ask_stories(&self) -> Result<Vec<u32>>

Return up to 200 latest Ask HN story item ids.

Source

pub fn get_show_stories(&self) -> Result<Vec<u32>>

Return up to 200 latest Show HN story item ids.

Source

pub fn get_job_stories(&self) -> Result<Vec<u32>>

Return up to 200 latest Job story item ids.

Source

pub fn get_updates(&self) -> Result<Updates>

Return a list of items and users that have been updated recently.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Err = <U as TryFrom<T>>::Err

Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T