Struct mwtitle::TitleCodec [−][src]
pub struct TitleCodec {
pub namespace_map: NamespaceMap,
// some fields omitted
}
parsing
only.Expand description
The TitleCodec
is responsible for parsing, normalizing and formatting
Title
s. See the crate-level documentation for an example of how to
construct one.
Fields
namespace_map: NamespaceMap
Implementations
Create a new title by parsing the provided input.
Create a new title by parsing the provided input. If the title has no
namespace part, then the namespace specified by default_namespace
is
used instead.
Get the title with namespace in pretty aka text form (spaces).
Fragments will not be included.
Panics
This will panic if the Title
is in a namespace that this TitleCodec
is unaware of.
Get the title with namespace in underscore aka dbkey form. This is potentially useful when you want to make a database query.
Fragments will not be included.
Panics
This will panic if the Title
is in a namespace that this TitleCodec
is unaware of.
Get the title with namespace in pretty aka text form (spaces), with the fragment, if one exists, appended.
Panics
This will panic if the Title
is in a namespace that this TitleCodec
is unaware of.
pub fn new(
namespace_map: NamespaceMap,
interwiki_set: InterwikiSet,
local_interwiki_set: InterwikiSet,
main_page: String,
lang: String,
legal_title_chars: String
) -> Result<Self>
pub fn new(
namespace_map: NamespaceMap,
interwiki_set: InterwikiSet,
local_interwiki_set: InterwikiSet,
main_page: String,
lang: String,
legal_title_chars: String
) -> Result<Self>
Construct a new TitleCodec
using the given fields.
In most cases it is easier to do so from one of the siteinfo methods.
pub fn new_from_iters<N: IntoIterator<Item = NamespaceInfo>, A: IntoIterator<Item = NamespaceAlias>, I: IntoIterator<Item = Interwiki>>(
namespaces: N,
namespace_aliases: A,
interwikis: I,
main_page: String,
lang: String,
legal_title_chars: String
) -> Result<Self>
pub fn new_from_iters<N: IntoIterator<Item = NamespaceInfo>, A: IntoIterator<Item = NamespaceAlias>, I: IntoIterator<Item = Interwiki>>(
namespaces: N,
namespace_aliases: A,
interwikis: I,
main_page: String,
lang: String,
legal_title_chars: String
) -> Result<Self>
Create a new TitleCodec
getting namespaces, namespace aliases, and interwikis from iterators.
This is supported on crate feature utils
only.
utils
only.Creates a TitleCodec
by parsing the contents of a JSON or GZipped JSON file.
Will accept the siteinfo-namespaces.json.gz
file from in the Wikimedia dumps.
If the file extension is gz
, decompresses from the GZip format before deserializing the JSON;
otherwise attempts to deserialize the file contents directly.
This is supported on crate feature utils
only.
utils
only.Creates a TitleCodec
by parsing the contents of a Read
type that contains the JSON
representation of a SiteInfoResponse
.
This is supported on crate feature utils
only.
utils
only.Creates a TitleCodec
by parsing the JSON representation of a SiteInfoResponse
.
Create a new TitleCodec
using the provided SiteInfo
.
The SiteInfo
must include a non-empty interwiki_map
field
to enable the resulting TitleCodec
to correctly parse titles with interwikis,
but an empty interwiki_map
is not an error.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for TitleCodec
impl Send for TitleCodec
impl Sync for TitleCodec
impl Unpin for TitleCodec
impl UnwindSafe for TitleCodec
Blanket Implementations
Mutably borrows from an owned value. Read more