pub struct Page { /* private fields */ }
Expand description
A Page
represents a wiki page on a specific wiki (Bot
). You can get
metadata about a page, its contents (in HTML or wikitext) and edit the
page.
Pages are obtained by calling bot.page("<title>")?
. Each page is Sync
and designed to easily Clone
d so it can be sent across multiple threads
for concurrent processing.
Most metadata lookups are internally batched and cached so it might not
reflect the live state on the wiki if someone has edited or modified the
page in the meantime. To get fresh information create a new Page
instance.
Saving a page will respect {{nobots}}
(if not disabled), wait as needed
for the configured rate limit and automatically implement edit conflict
detection.
Implementations§
Source§impl Page
impl Page
Sourcepub fn as_title(&self) -> &Title
pub fn as_title(&self) -> &Title
Get a reference to the underlying mwtitle::Title
Sourcepub fn as_file(&self) -> Option<File>
Available on crate feature upload
only.
pub fn as_file(&self) -> Option<File>
upload
only.If it is a file, get a File
instance
Sourcepub fn is_category(&self) -> bool
pub fn is_category(&self) -> bool
Whether this page refers to a category
Sourcepub async fn id(&self) -> Result<Option<u32>>
pub async fn id(&self) -> Result<Option<u32>>
Get the page’s internal database ID, if it exists
Sourcepub async fn is_redirect(&self) -> Result<bool>
pub async fn is_redirect(&self) -> Result<bool>
Whether the page is a redirect or not
Sourcepub async fn associated_page(&self) -> Result<Page>
pub async fn associated_page(&self) -> Result<Page>
The associated page for this page (subject page for a talk page or talk page for a subject page)
Sourcepub async fn touched(&self) -> Result<Option<Timestamp>>
pub async fn touched(&self) -> Result<Option<Timestamp>>
Get the “touched” timestamp, if the page exists.
From the MediaWiki documentation:
This timestamp is updated whenever the page changes in a way requiring it to be re-rendered, invalidating caches. Aside from editing, this includes permission changes, creation or deletion of linked pages, and alteration of contained templates.
Sourcepub async fn latest_revision_id(&self) -> Result<Option<u64>>
pub async fn latest_revision_id(&self) -> Result<Option<u64>>
Get the ID of the latest revision, if the page exists.
Sourcepub async fn redirect_target(&self) -> Result<Option<Page>>
pub async fn redirect_target(&self) -> Result<Option<Page>>
If this page is a redirect, get the Page
it targets
Sourcepub async fn language_links(&self) -> Result<Option<HashMap<String, String>>>
Available on crate feature generators
only.
pub async fn language_links(&self) -> Result<Option<HashMap<String, String>>>
generators
only.Get the inter-language links of the latest revision, if the page exists.
Sourcepub async fn categories(&self) -> Result<Option<Vec<String>>>
Available on crate feature generators
only.
pub async fn categories(&self) -> Result<Option<Vec<String>>>
generators
only.Get the categories of the latest revision, if the page exists.
Sourcepub async fn templates(
&self,
only: Option<Vec<String>>,
) -> Result<Option<Vec<String>>>
Available on crate feature generators
only.
pub async fn templates( &self, only: Option<Vec<String>>, ) -> Result<Option<Vec<String>>>
generators
only.Get the templates used in the latest revision, if the page exists.
Sourcepub async fn html(&self) -> Result<ImmutableWikicode>
pub async fn html(&self) -> Result<ImmutableWikicode>
Get Parsoid HTML for self.baserevid if it’s set, or the latest revision otherwise
Sourcepub async fn revision_html(&self, revid: u64) -> Result<ImmutableWikicode>
pub async fn revision_html(&self, revid: u64) -> Result<ImmutableWikicode>
Get Parsoid HTML for the specified revision
Sourcepub async fn wikitext(&self) -> Result<String>
pub async fn wikitext(&self) -> Result<String>
Get wikitext for self.baserevid if it’s set, or the latest revision otherwise