Struct mwtitle::Title[][src]

pub struct Title { /* fields omitted */ }
Expand description

Represents a MediaWiki title. A title can be broken down into the following attributes: [[interwiki:ns:db_key#fragment]].

  • interwiki: Optional prefix pointing to another site
  • namespace: Numerical ID corresponding to a MediaWiki namespace
  • dbkey: Page name, with underscores instead of spaces
  • fragment: Optional anchor for a specific section
// ns1 is Talk, so this is [[Talk:Main Page]]
let title = Title::new_unchecked(1, "Main_Page");
assert_eq!(title.namespace(), 1);
assert_eq!(title.dbkey(), "Main_Page");
assert!(title.interwiki().is_none());
assert!(title.fragment().is_none());
let title = title.with_fragment("Section 1");
assert_eq!(title.fragment(), Some("Section 1"));

Implementations

Create a new Title, with no validation on the namespace or text parts. Good if you’re getting the title from a trusted place like the API. If the namespace does not exist in the TitleCodec this is used with it can result in panics.

Note that text is supposed to be the database key, with no namespace prefix.

Set a fragment.

Remove the fragment.

Get the namespace ID.

Get the dbkey.

Get the fragment, if there is one.

Get the interwiki, if there is one.

Whether this title was created via a local interwiki link.

If the title is a local page that could exist, basically not an interwiki link, nor a fragment-only link, nor a special page.

Whether this title refers to a file.

Whether this title refers to a category.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.