pub struct TitleCodec { /* private fields */ }
Available on crate feature parsing only.
Expand description

The TitleCodec is responsible for parsing, normalizing and formatting Titles. See the crate-level documentation for an example of how to construct one.

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.

Construct a new TitleCodec using the given fields.

In most cases it is easier to do so from one of the siteinfo methods.

Create a new TitleCodec getting namespaces, namespace aliases, and interwikis from iterators.

Available on crate feature 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.

Available on crate feature utils only.

Creates a TitleCodec by parsing the contents of a Read type that contains the JSON representation of a SiteInfoResponse.

Available on crate feature 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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. 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.