Skip to main content

Tag

Enum Tag 

Source
#[repr(u8)]
pub enum Tag {
Show 59 variants Area = 0, Base = 1, Br = 2, Col = 3, Embed = 4, Hr = 5, Img = 6, Input = 7, Link = 8, Meta = 9, Param = 10, Source = 11, Track = 12, Wbr = 13, A = 14, Abbr = 15, Article = 16, Aside = 17, B = 18, Body = 19, Button = 20, Div = 21, Em = 22, Footer = 23, Form = 24, H1 = 25, H2 = 26, H3 = 27, H4 = 28, H5 = 29, H6 = 30, Head = 31, Header = 32, Html = 33, I = 34, Iframe = 35, Li = 36, Main = 37, Nav = 38, Ol = 39, P = 40, Pre = 41, Script = 42, Section = 43, Select = 44, Span = 45, Strong = 46, Style = 47, Table = 48, Tbody = 49, Td = 50, Textarea = 51, Th = 52, Thead = 53, Title = 54, Tr = 55, Ul = 56, Video = 57, Unknown = 255,
}
Expand description

Interned HTML tag enum. Known HTML tag names interned as a u8 discriminant.

Comparison becomes a single integer compare instead of a string compare. The first 14 variants (0..14) are void elements — is_void() exploits this for a branch-free check.

Variants§

§

Area = 0

<area>

§

Base = 1

<base>

§

Br = 2

<br>

§

Col = 3

<col>

§

Embed = 4

<embed>

§

Hr = 5

<hr>

§

Img = 6

<img>

§

Input = 7

<input>

<link>

§

Meta = 9

<meta>

§

Param = 10

<param>

§

Source = 11

<source>

§

Track = 12

<track>

§

Wbr = 13

<wbr>

§

A = 14

<a>

§

Abbr = 15

<abbr>

§

Article = 16

<article>

§

Aside = 17

<aside>

§

B = 18

<b>

§

Body = 19

<body>

§

Button = 20

<button>

§

Div = 21

<div>

§

Em = 22

<em>

§

Footer = 23

<footer>

§

Form = 24

<form>

§

H1 = 25

<h1>

§

H2 = 26

<h2>

§

H3 = 27

<h3>

§

H4 = 28

<h4>

§

H5 = 29

<h5>

§

H6 = 30

<h6>

§

Head = 31

<head>

§

Header = 32

<header>

§

Html = 33

<html>

§

I = 34

<i>

§

Iframe = 35

<iframe>

§

Li = 36

<li>

§

Main = 37

<main>

§

Nav = 38

<nav>

§

Ol = 39

<ol>

§

P = 40

<p>

§

Pre = 41

<pre>

§

Script = 42

<script>

§

Section = 43

<section>

§

Select = 44

<select>

§

Span = 45

<span>

§

Strong = 46

<strong>

§

Style = 47

<style>

§

Table = 48

<table>

§

Tbody = 49

<tbody>

§

Td = 50

<td>

§

Textarea = 51

<textarea>

§

Th = 52

<th>

§

Thead = 53

<thead>

§

Title = 54

<title>

§

Tr = 55

<tr>

§

Ul = 56

<ul>

§

Video = 57

<video>

§

Unknown = 255

Any tag name not in the known set.

Implementations§

Source§

impl Tag

Source

pub fn from_bytes(name: &[u8]) -> Tag

Look up a tag by its raw byte name using a compile-time perfect hash.

Case-insensitive: the input is lowercased inline on a stack buffer before the PHF lookup, avoiding any heap allocation.

Source

pub const fn is_void(self) -> bool

Returns true if this is a void element (self-closing, no children).

Branch-free: exploits the fact that void elements occupy discriminants 0..14.

Source

pub const fn is_raw_text(self) -> bool

Returns true if this is a raw text element (<script>, <style>).

Raw text elements’ content must not be entity-escaped during serialization, and the tokenizer enters a special raw-text mode for them.

Source

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

Returns the canonical lowercase tag name, or None for Tag::Unknown.

Trait Implementations§

Source§

impl Clone for Tag

Source§

fn clone(&self) -> Tag

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Tag

Source§

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

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

impl Display for Tag

Source§

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

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

impl Hash for Tag

Source§

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

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 Tag

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Tag

Source§

impl Eq for Tag

Source§

impl StructuralPartialEq for Tag

Auto Trait Implementations§

§

impl Freeze for Tag

§

impl RefUnwindSafe for Tag

§

impl Send for Tag

§

impl Sync for Tag

§

impl Unpin for Tag

§

impl UnsafeUnpin for Tag

§

impl UnwindSafe for Tag

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.