pub struct Client { /* private fields */ }Expand description
HTTP client to get Parsoid HTML from MediaWiki’s Rest APIs
Note: This requires the http feature is enabled (it is by default).
Implementations§
source§impl Client
impl Client
sourcepub fn new(base_url: &str, user_agent: &str) -> Result<Self>
pub fn new(base_url: &str, user_agent: &str) -> Result<Self>
Create a new Client. base_url should either point to rest.php or
Restbase. For Wikimedia projects it would look something like:
https://en.wikipedia.org/api/rest_v1. For other wikis it might be:
https://wiki.example.org/rest.php/wiki.example.org/v3.
(Note: no trailing slash on either endpoint style.)
sourcepub fn new_with_client(base_url: &str, http: HttpClient) -> Self
pub fn new_with_client(base_url: &str, http: HttpClient) -> Self
Create a new Client using an existing reqwest::Client. See the
documentation for new() for what base_url should be. This is
primarily useful when you are already making calls to the wiki and
want to share connection pools and cookie state.
sourcepub async fn get(&self, page: &str) -> Result<ImmutableWikicode>
pub async fn get(&self, page: &str) -> Result<ImmutableWikicode>
Get a Wikicode instance for the specified page
sourcepub async fn get_revision(
&self,
page: &str,
revid: u64
) -> Result<ImmutableWikicode>
pub async fn get_revision(
&self,
page: &str,
revid: u64
) -> Result<ImmutableWikicode>
Get a Wikicode instance for the specified page at the specified revision
sourcepub async fn get_raw(&self, page: &str) -> Result<String>
pub async fn get_raw(&self, page: &str) -> Result<String>
Get the Parsoid HTML for the specified page
sourcepub async fn get_revision_raw(&self, page: &str, revid: u64) -> Result<String>
pub async fn get_revision_raw(&self, page: &str, revid: u64) -> Result<String>
Get the Parsoid HTML for the specified page at the specified revision
sourcepub async fn transform_to_html(
&self,
wikitext: &str
) -> Result<ImmutableWikicode>
pub async fn transform_to_html(
&self,
wikitext: &str
) -> Result<ImmutableWikicode>
Get a Wikicode instance for the specified wikitext
sourcepub async fn transform_to_html_raw(&self, wikitext: &str) -> Result<String>
pub async fn transform_to_html_raw(&self, wikitext: &str) -> Result<String>
Get the Parsoid HTML for the specified wikitext
sourcepub async fn transform_to_wikitext<C: APICode>(&self, code: &C) -> Result<String>
pub async fn transform_to_wikitext<C: APICode>(&self, code: &C) -> Result<String>
Get the wikitext for the specified Parsoid HTML