Struct mwtitle::NamespaceMap [−][src]
pub struct NamespaceMap { /* fields omitted */ }
Implementations
Creates a NamespaceMap
from a SiteInfo
.
This is supported on crate feature utils
only.
utils
only.Creates a NamespaceMap
by parsing the contents of a JSON or GZipped JSON file
like siteinfo-namespaces.json.gz
or siteinfo-namespaces.json
in the Wikimedia dumps.
If the file extension is gz
, decompresses from the GZip format before decoding the JSON.
pub fn from_namespaces_and_namespace_aliases<NS: IntoIterator<Item = NamespaceInfo>, AL: IntoIterator<Item = NamespaceAlias>>(
namespaces: NS,
namespace_aliases: AL
) -> Result<Self>
pub fn from_namespaces_and_namespace_aliases<NS: IntoIterator<Item = NamespaceInfo>, AL: IntoIterator<Item = NamespaceAlias>>(
namespaces: NS,
namespace_aliases: AL
) -> Result<Self>
Constructs a NamespaceMap
from an iterator yielding NamespaceInfo
s
and an iterator yielding NamespaceAlias
es.
Errors
If the namespacealiases
field contains any id
s that are not found in the namespaces
field of the SiteInfo
,
fails and returns Err(Error::UnknownAliases(unrecognized_ids))
.
pub fn from_iters<NS: IntoIterator<Item = NI>, NI: IntoIterator<Item = (String, String)>, AL: IntoIterator<Item = (String, i32)>>(
namespaces: NS,
namespace_aliases: AL
) -> Result<Self>
pub fn from_iters<NS: IntoIterator<Item = NI>, NI: IntoIterator<Item = (String, String)>, AL: IntoIterator<Item = (String, i32)>>(
namespaces: NS,
namespace_aliases: AL
) -> Result<Self>
Create a NamespaceMap
from two iterators. The first iterator represents
namespaces and contains (key, value): (String, String)
tuples that represent the fields
of a NamespaceInfo
. The second contains (alias, id): (String, i32)
tuples
that each represent a NamespaceAlias
.
This is supported on crate feature utils
only.
utils
only.Creates a NamespaceMap
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 NamespaceMap
by parsing the JSON representation of a SiteInfoResponse
.
Returns the attributes of the namespace when given a valid namespace ID.
pub fn get_info<'a, 'b, N: Into<Namespace<'b>>>(
&'a self,
namespace: N
) -> Option<&NamespaceInfo>
pub fn get_info<'a, 'b, N: Into<Namespace<'b>>>(
&'a self,
namespace: N
) -> Option<&NamespaceInfo>
Returns the attributes of the namespace when given a valid namespace ID or name or alias.
Returns the ID of the namespace when given a valid namespace ID or name or alias. In case of an ID, this unnecessarily looks up the ID in the map.
Equivalent of Language::getNsIndex()
.
Returns the local name of the namespace when given a valid namespace ID or name or alias.
Returns case-sensitivity of the first letter of titles in the namespace when given a valid namespace ID or name or alias.
pub fn get_canonical_name<'a, 'b, N: Into<Namespace<'b>>>(
&'a self,
namespace: N
) -> Option<&'a str>
pub fn get_canonical_name<'a, 'b, N: Into<Namespace<'b>>>(
&'a self,
namespace: N
) -> Option<&'a str>
Returns canonical name for a namespace ID or name or alias, if it is valid and if that namespace has a canonical name.
Whether the first letter of titles in the namespace is always capitalized.
Equivalent of NamespaceInfo::isCapitalized()
.
Get the title with namespace in pretty aka text form (spaces).
Fragments will not be included.
Returns None
if the title’s namespace is not in the map.
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.
Returns None
if the title’s namespace is not in the map
Get the title with namespace in pretty aka text form (spaces), with the fragment, if one exists, appended.
Returns None
if the title’s namespace is not in the map.
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for NamespaceMap
impl Send for NamespaceMap
impl Sync for NamespaceMap
impl Unpin for NamespaceMap
impl UnwindSafe for NamespaceMap
Blanket Implementations
Mutably borrows from an owned value. Read more