Skip to main content

Html

Struct Html 

Source
pub struct Html<'s> { /* private fields */ }
Expand description

解析好的文档。借用源字符串(输入含 \r 或 NUL 时持有规范化后的副本)。

Implementations§

Source§

impl<'s> Html<'s>

Source

pub fn parse(html: &'s str) -> Html<'s>

解析整个 HTML 文档。永不失败:任何输入都会得到一棵树。

Source

pub fn root(&self) -> NodeRef<'_>

文档根节点(不是 <html> 元素,是它的父节点)。

Source

pub fn len(&self) -> usize

节点总数。节点 id 的范围是 0..len(),可以用来开按节点下标索引的数组。

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, id: NodeId) -> NodeRef<'_>

Source

pub fn body(&self) -> NodeRef<'_>

第一个 <body>,没有时返回根节点。

Source§

impl<'a> Html<'a>

Source

pub fn select<'s>(&'a self, sel: &'s Selector) -> Select<'a, 's> ⓘ

文档里匹配选择器的所有元素,按文档顺序。

Trait Implementations§

Source§

impl Debug for Html<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> Freeze for Html<'s>

§

impl<'s> RefUnwindSafe for Html<'s>

§

impl<'s> Send for Html<'s>

§

impl<'s> Sync for Html<'s>

§

impl<'s> Unpin for Html<'s>

§

impl<'s> UnsafeUnpin for Html<'s>

§

impl<'s> UnwindSafe for Html<'s>

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> 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, 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.