pub struct HttpClients {
    pub html: Client,
    pub gql: Client,
    pub website_rss_url: String,
    pub github_rest_url: String,
    pub github_gql_url: String,
    pub repo_owner: String,
    pub repo_name: String,
    pub discussion_category: String,
    pub lookback_days: i64,
}
Expand description

Monostruct containing the HTML and GraphQL clients used to create the discussion, along with the necessary URLs.

Fields§

§html: Client

HTML client for accessing the RSS feed, blog post, and GitHub REST API.

§gql: Client

GraphQL client for accessing the GitHub GraphQL API. This client must be created with the following headers, using ClientBuilder::default_headers:

  • Accept: application/vnd.github+json
  • Authorization: <GitHub token>
  • User-Agent: <appropriate user agent name>
  • X-Github-Next-Global-ID: 1
§website_rss_url: String

URL for the blog’s RSS feed.

§github_rest_url: String

URL for GitHub REST API, typically https://api.github.com

§github_gql_url: String

URL for GitHub GraphQL API, typically https://api.github.com/graphql

§repo_owner: String

Owner of the repository hosting the comments.

§repo_name: String

Name of the repository hosting the comments

§discussion_category: String

Name of the discussion category that the comments should be posted under.

§lookback_days: i64

The number of days to look back in history, to check if a previous discussion occurred. Limit is disabled if set to 0.

Implementations§

source§

impl HttpClients

source

pub fn init() -> Arc<Self>

Create the reqwest clients, and pull the other values from environment variables. These are assumed to be formatted like the default values available in GitHub Actions, except for DISCUSSION_CATEGORY and LOOKBACK_DAYS:

use std::env;
use rss_autogen_giscus::HttpClients;

env::set_var("WEBSITE_RSS_URL", "https://rss.cbc.ca/lineup/topstories.xml");
env::set_var("GITHUB_TOKEN", "secret_github_pat");
env::set_var("GITHUB_REPOSITORY_OWNER", "microsoft");
env::set_var("GITHUB_REPOSITORY", "microsoft/vscode");
env::set_var("DISCUSSION_CATEGORY", "CBC News");
env::set_var("LOOKBACK_DAYS", "0");

let clients = HttpClients::init();

Trait Implementations§

source§

impl Clone for HttpClients

source§

fn clone(&self) -> HttpClients

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HttpClients

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> IsFieldType<T> for T