Skip to main content

Mode

Enum Mode 

Source
pub enum Mode {
    Generic,
    Html,
    Xhtml,
}
Expand description

The translator flavour: which pseudo-class overrides, name-casing rules, and :lang() language source to apply.

Html and Xhtml share the HTML pseudo-class overrides; only Html ASCII-lowercases element and attribute names and folds HTML’s legacy case-insensitive attribute values, and only Xhtml reads xml:lang.

Pseudo-classes with no static equivalent (:hover, :visited, :focus, :dir(), …) translate to an unmatchable [0] in every flavour, rather than erroring.

The enum is deliberately exhaustive: these three are the document flavours CSS selector matching distinguishes, and callers benefit more from exhaustive match than the crate would from room to add a fourth.

Variants§

§

Generic

Plain CSS/XPath semantics: case-sensitive names, no HTML-specific pseudo-classes, and :lang() via XPath’s own lang() function.

This is the Default, as the flavour that assumes least about the document.

§

Html

An HTML document, as an HTML parser leaves it: element and attribute names are ASCII-lowercased, HTML’s legacy case-insensitive attribute values (type, rel, …) compare without regard to case, and :link, :checked, :disabled/:enabled, :required/:optional and :lang() take their static HTML meaning over the elements HTML defines them for. :lang() reads the nearest @lang ancestor.

§

Xhtml

XHTML: the same HTML pseudo-class semantics as Mode::Html, but case is preserved (XHTML is XML, so both names and those attribute values are case-sensitive) and :lang() reads xml:lang as well as lang, preferring xml:lang when both sit on the nearest ancestor.

Implementations§

Source§

impl Mode

Source

pub fn as_str(self) -> &'static str

The mode’s lowercase name: "generic", "html" or "xhtml".

The inverse of the FromStr impl, which accepts these three names in any ASCII case.

Trait Implementations§

Source§

impl Clone for Mode

Source§

fn clone(&self) -> Mode

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 Copy for Mode

Source§

impl Debug for Mode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Mode

Source§

fn default() -> Mode

Returns the “default value” for a type. Read more
Source§

impl Display for Mode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Mode

Source§

impl FromStr for Mode

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parse "generic", "html" or "xhtml", ignoring ASCII case, so that a mode read from a CLI flag or a config file needs no hand-written match in every caller.

Nothing else is accepted — not an abbreviation, not "xml" — and the name is compared as-is, so surrounding whitespace is the caller’s to trim.

Source§

type Err = ParseModeError

The associated error which can be returned from parsing.
Source§

impl Hash for Mode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Mode

Source§

fn eq(&self, other: &Mode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Mode

Auto Trait Implementations§

§

impl Freeze for Mode

§

impl RefUnwindSafe for Mode

§

impl Send for Mode

§

impl Sync for Mode

§

impl Unpin for Mode

§

impl UnsafeUnpin for Mode

§

impl UnwindSafe for Mode

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.