pub struct Node {
pub node_type: NodeType,
pub children: Vec<Node>,
}Fields§
§node_type: NodeType§children: Vec<Node>Implementations§
Source§impl Node
impl Node
const MAX_SEARCH_DEPTH: usize = 256
pub fn new_text(text: String) -> Self
pub fn new_element(name: String, attrs: BTreeMap<String, String>) -> Self
pub fn new_element_direct( name: String, attrs: BTreeMap<String, String>, id: Option<String>, classes: Vec<String>, ) -> Self
Sourcepub fn empty_root() -> Self
pub fn empty_root() -> Self
子を持たない html ルート要素を返す。parse_html が返すルートと同じ形状で、
DOM ブリッジを真実源とするインクリメンタル再レイアウト時、HTML パースを
省略するためのプレースホルダとして使う(描画ツリーはブリッジから再構築される)。
Sourcepub fn get_element_by_id(&self, target_id: &str) -> Option<&Node>
pub fn get_element_by_id(&self, target_id: &str) -> Option<&Node>
ID による要素探索(深さ優先・最初に一致した参照を返す)。
fn get_element_by_id_depth( &self, target_id: &str, depth: usize, ) -> Option<&Node>
Sourcepub fn get_elements_by_class_name<'a>(
&'a self,
target_class: &str,
out: &mut Vec<&'a Node>,
)
pub fn get_elements_by_class_name<'a>( &'a self, target_class: &str, out: &mut Vec<&'a Node>, )
クラス名による要素収集(深さ優先・ゼロアロケーション走査)。
fn get_elements_by_class_name_depth<'a>( &'a self, target_class: &str, out: &mut Vec<&'a Node>, depth: usize, )
Sourcepub fn get_elements_by_tag_name<'a>(
&'a self,
target_tag: &str,
out: &mut Vec<&'a Node>,
)
pub fn get_elements_by_tag_name<'a>( &'a self, target_tag: &str, out: &mut Vec<&'a Node>, )
タグ名による要素収集(大文字小文字無視)。
fn get_elements_by_tag_name_depth<'a>( &'a self, target_tag: &str, out: &mut Vec<&'a Node>, depth: usize, )
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
ツリー内の全テキストを連結して取得する(単一バッファ追記方式)。
fn collect_text(&self, out: &mut String, depth: usize)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more