[][src]Struct mediawiki::title::Title

pub struct Title { /* fields omitted */ }

Title struct

Implementations

impl Title[src]

pub fn new(title: &str, namespace_id: NamespaceID) -> Title[src]

Constructor, where un-prefixed title and namespace are known. Assumes title has correct capitalization

pub fn new_from_full(full_title: &str, api: &Api) -> Self[src]

Constructor, where full namespace-prefixed title is known. Uses Api to parse valid namespaces

pub fn new_from_api_result(data: &Value) -> Title[src]

Constructor, used by Api::result_array_to_titles

pub fn namespace_id(&self) -> NamespaceID[src]

Returns the namespace ID

pub fn namespace_name<'a>(&self, api: &'a Api) -> Option<&'a str>[src]

Returns the canonical namespace text, based on the Api

pub fn local_namespace_name<'a>(&self, api: &'a Api) -> Option<&'a str>[src]

Returns the local namespace text, based on the Api

pub fn with_underscores(&self) -> String[src]

Returns the non-namespace-prefixed title, with underscores

pub fn pretty(&self) -> &str[src]

Returns the non-namespace-prefixed title, with spaces instead of underscores

pub fn full_with_underscores(&self, api: &Api) -> Option<String>[src]

Returns the namespace-prefixed title, with underscores

pub fn full_pretty(&self, api: &Api) -> Option<String>[src]

Returns the namespace-prefixed title, with spaces instead of underscores

pub fn spaces_to_underscores(s: &str) -> String[src]

Changes all spaces to underscores

pub fn underscores_to_spaces(s: &str) -> String[src]

Changes all underscores to spaces

pub fn first_letter_uppercase(s: &str) -> String[src]

Changes the first letter to uppercase. Enforces spaces instead of underscores.

pub fn toggle_talk(&mut self)[src]

Changes this Title to refer to the other member of the corresponding article-talk page pair for this page. Won't change Special pages.

Examples

use mediawiki::title::Title;
let mut title1 = Title::new("Test", 0);
title1.toggle_talk();
assert_eq!(title1, Title::new("Test", 1));

let mut title2 = Title::new("Test", 1);
title2.toggle_talk();
assert_eq!(title2, Title::new("Test", 0));

let mut title3 = Title::new("Test", -1);
title3.toggle_talk();
assert_eq!(title3, Title::new("Test", -1));

pub fn into_toggle_talk(self) -> Self[src]

Returns a new Title referring to the other member of the corresponding article-talk page pair for this page. Won't change Special pages.

Examples

use mediawiki::title::Title;
assert_eq!(Title::new("Test", 0).into_toggle_talk(),
    Title::new("Test", 1));

assert_eq!(Title::new("Test", 1).into_toggle_talk(),
    Title::new("Test", 0));

assert_eq!(Title::new("Test", -1).into_toggle_talk(),
    Title::new("Test", -1));

Trait Implementations

impl Clone for Title[src]

impl Debug for Title[src]

impl Eq for Title[src]

impl Hash for Title[src]

impl PartialEq<Title> for Title[src]

impl StructuralEq for Title[src]

impl StructuralPartialEq for Title[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.