pub struct Title { /* private fields */ }
Available on crate feature
utils
only.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 sitenamespace
: Numerical ID corresponding to a MediaWiki namespacedbkey
: Page name, with underscores instead of spacesfragment
: 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§
Source§impl Title
impl Title
Sourcepub fn new_unchecked(namespace: i32, text: &str) -> Title
pub fn new_unchecked(namespace: i32, text: &str) -> Title
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.
Sourcepub fn with_fragment(self, fragment: &str) -> Title
pub fn with_fragment(self, fragment: &str) -> Title
Set a fragment.
Sourcepub fn remove_fragment(self) -> Title
pub fn remove_fragment(self) -> Title
Remove the fragment.
Sourcepub fn is_local_interwiki(&self) -> bool
pub fn is_local_interwiki(&self) -> bool
Whether this title was created via a local interwiki link.
Sourcepub fn is_local_page(&self) -> bool
pub fn is_local_page(&self) -> bool
If the title is a local page that could exist, basically not an interwiki link, nor a fragment-only link, nor a special page.
Sourcepub fn is_category(&self) -> bool
pub fn is_category(&self) -> bool
Whether this title refers to a category.
Trait Implementations§
Source§impl Ord for Title
impl Ord for Title
Source§impl PartialOrd for Title
impl PartialOrd for Title
impl Eq for Title
impl StructuralPartialEq for Title
Auto Trait Implementations§
impl Freeze for Title
impl RefUnwindSafe for Title
impl Send for Title
impl Sync for Title
impl Unpin for Title
impl UnwindSafe for Title
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more