pub struct Title { /* private fields */ }
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 = unsafe { Title::new_unchecked(1, "Main_Page".into()) };
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".into());
assert_eq!(title.fragment(), Some("Section 1"));

Implementations

Create a new Title from a namespace ID and database key (title without the namespace prefix), with no validation on the namespace or text parts.

Good if you’re getting the title from a trusted place like the API.

The dbkey should have underscores and be normalized and sanitized as if it has been processed by TitleCodec::new_title. The namespace must exist in the TitleCodec or NamespaceMap that will format this title.

Safety

If the namespace doesn’t exist in the TitleCodec or NamespaceMap, some methods, like TitleCodec::to_pretty, will panic.

If the dbkey hasn’t been normalized and sanitized, the ordering implementations ( Eq, PartialEq, Ord, PartialOrd) for the Title aren’t guaranteed to give the correct results.

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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.