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_attribute(&self, name: &str) -> Option<&str>
pub fn get_attribute(&self, name: &str) -> Option<&str>
要素の属性値を取得する。
Sourcepub fn dataset(&self) -> BTreeMap<String, String>
pub fn dataset(&self) -> BTreeMap<String, String>
W3C HTML5 §3.2.6.2 / DOMStringMap: data-* 属性から camelCase の dataset マップを抽出する。
Sourcepub fn set_dataset_property(
&mut self,
prop: &str,
value: &str,
) -> Result<String, DatasetError>
pub fn set_dataset_property( &mut self, prop: &str, value: &str, ) -> Result<String, DatasetError>
W3C HTML5 §3.2.6.2: dataset プロパティを設定し、対応する data-* 属性を更新する。
Sourcepub fn remove_dataset_property(
&mut self,
prop: &str,
) -> Result<Option<String>, DatasetError>
pub fn remove_dataset_property( &mut self, prop: &str, ) -> Result<Option<String>, DatasetError>
W3C HTML5 §3.2.6.2: dataset プロパティを削除し、対応する data-* 属性を削除する。
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