Struct mwbot::Page

source ·
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 Cloned 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

source

pub fn title(&self) -> &str

Get the title of the page

source

pub fn as_title(&self) -> &Title

Get a reference to the underlying mwtitle::Title

source

pub fn namespace(&self) -> i32

Get the namespace ID of the page

source

pub fn is_file(&self) -> bool

Whether this page refers to a file

source

pub fn as_file(&self) -> Option<File>

Available on crate feature upload only.

If it is a file, get a File instance

source

pub fn is_category(&self) -> bool

Whether this page refers to a category

source

pub async fn exists(&self) -> Result<bool>

Whether the page exists or not

source

pub async fn id(&self) -> Result<Option<u32>>

Get the page’s internal database ID, if it exists

source

pub async fn url(&self) -> Result<&str>

Get the canonical URL for this page

source

pub async fn is_redirect(&self) -> Result<bool>

Whether the page is a redirect or not

source

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)

source

pub async fn redirect_target(&self) -> Result<Option<Page>>

If this page is a redirect, get the Page it targets

source

pub async fn html(&self) -> Result<ImmutableWikicode>

Get Parsoid HTML for self.baserevid if it’s set, or the latest revision otherwise

source

pub async fn revision_html(&self, revid: u64) -> Result<ImmutableWikicode>

Get Parsoid HTML for the specified revision

source

pub async fn wikitext(&self) -> Result<String>

Get wikitext for self.baserevid if it’s set, or the latest revision otherwise

source

pub async fn save<S: Into<Saveable>>( self, edit: S, opts: &SaveOptions ) -> Result<(Page, EditResponse)>

Save the page using the specified HTML

source

pub async fn undo( self, from: u64, to: Option<u64>, opts: &SaveOptions ) -> Result<(Page, EditResponse)>

Reverses edits to revision IDs from through to. If to is passed None, only one revision specified in from will be undone.

Trait Implementations§

source§

impl Clone for Page

source§

fn clone(&self) -> Page

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 Page

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl !UnwindSafe for Page

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> 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 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> ToOwned for T
where 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 T
where 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 T
where 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