Skip to main content

SiteConfig

Struct SiteConfig 

Source
pub struct SiteConfig { /* private fields */ }
Expand description

Compiled per-wiki configuration. Cheap to share (Clone clones the compiled tables); build one per wiki and reuse it for every parse.

Implementations§

Source§

impl SiteConfig

Source

pub fn from_preset_json(json: &str) -> Result<SiteConfig, ConfigError>

Loads a configuration from preset JSON (the schema written by cargo xtask gen-siteconfig, not raw meta=siteinfo output).

Source

pub fn enwiki() -> &'static SiteConfig

English Wikipedia (en.wikipedia.org) preset.

Source

pub fn ruwiki() -> &'static SiteConfig

Russian Wikipedia (ru.wikipedia.org) preset.

Source

pub fn generic() -> &'static SiteConfig

A plain-MediaWiki preset: canonical English namespaces, core magic words and extension tags, default protocols. Suitable for wikis you have no siteinfo for.

Source§

impl SiteConfig

Source

pub fn builder( lang: impl Into<String>, site_name: impl Into<String>, ) -> SiteConfigBuilder

Starts building a configuration for a wiki with the given content language code and site name.

Source

pub fn lang(&self) -> &str

The wiki’s content-language code (e.g. "ru").

Source

pub fn site_name(&self) -> &str

The wiki’s site name (e.g. "Википедия"), the {{SITENAME}} value.

Source

pub fn resolve_namespace(&self, prefix: &str) -> Option<Namespace>

Resolves a namespace prefix (canonical, localized or alias; case-insensitive, underscore/space-insensitive) to a namespace.

Source

pub fn namespace_name(&self, ns: Namespace) -> Option<&str>

The localized name of a namespace this config defines (empty string for main).

Source

pub fn ns_first_letter(&self, ns: Namespace) -> bool

Whether titles in ns are first-letter case-insensitive (true for unknown ids, matching MediaWiki’s default).

Source

pub fn resolve_magic_word(&self, alias: &str) -> Option<&str>

Resolves a magic-word alias to its stable id, honoring per-word case sensitivity.

Source

pub fn redirect_aliases(&self) -> &[String]

The accepted redirect keywords (#REDIRECT, #ПЕРЕНАПРАВЛЕНИЕ, …), folded.

Source

pub fn ext_tag(&self, name: &str) -> Option<ExtTagContent>

How the given extension tag treats its body, if the tag is registered. Lookup is case-insensitive (<NoWiki> works).

Source

pub fn protocols(&self) -> &[String]

External-link protocols, longest first (so https:// wins over http:// — and both over //).

Source

pub fn trail_accepts(&self, c: char) -> bool

Whether c may extend a link label past the closing brackets ([[dog]]s).

Source

pub fn is_interwiki_prefix(&self, prefix: &str) -> bool

Whether prefix is a known interwiki prefix (case-insensitive).

The RFC/PMID/ISBN magic-link toggles.

Source

pub fn lang_converter(&self) -> bool

Whether LanguageConverter markup (-{ … }-) is recognized on this wiki.

Source

pub fn months(&self) -> &MonthNames

The localized month names (genitive/nominative/abbreviated) used by the signature-timestamp matcher.

Trait Implementations§

Source§

impl Clone for SiteConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SiteConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.