parse-html 0.4.1

A simple Rust project to parse HTML.
Documentation
use crate::dom::{
    search_by_attr::{search_all_element_by_attr, search_element_by_attr},
    search_by_tag_name::{search_all_element_by_tag_name, search_element_by_tag_name},
};

#[derive(Debug, PartialEq, Clone)]
pub enum Node {
    Element(ElementNode),
    Text(String),
}

#[derive(Debug, PartialEq, Clone)]
pub struct ElementNode {
    pub tag_name: String,
    pub attributes: Vec<(String, String)>,
    pub children: Vec<Node>,
}

impl ElementNode {
    pub fn get_by_id(&self, id_value: &str) -> Option<&ElementNode> {
        for node in &self.children {
            if let Some(found) = search_element_by_attr(node, "id", id_value) {
                return Some(found);
            }
        }
        None
    }

    pub fn get_all_by_id(&self, id_value: &str) -> Vec<&ElementNode> {
        let mut list_found = vec![];
        for node in &self.children {
            list_found.extend(search_all_element_by_attr(node, "id", id_value));
        }
        list_found
    }

    pub fn get_by_class(&self, value: &str) -> Option<&ElementNode> {
        for node in &self.children {
            if let Some(found) = search_element_by_attr(node, "class", value) {
                return Some(found);
            }
        }
        None
    }

    pub fn get_all_by_class(&self, value: &str) -> Vec<&ElementNode> {
        let mut list_found = vec![];
        for node in &self.children {
            list_found.extend(search_all_element_by_attr(node, "class", value));
        }
        list_found
    }

    pub fn get_by_tag_name(&self, tag_name: &str) -> Option<&ElementNode> {
        for node in &self.children {
            if let Some(found) = search_element_by_tag_name(node, tag_name) {
                return Some(found);
            }
        }
        None
    }

    pub fn get_all_by_tag_name(&self, tag_name: &str) -> Vec<&ElementNode> {
        let mut list_found = vec![];
        for node in &self.children {
            list_found.extend(search_all_element_by_tag_name(node, tag_name));
        }
        list_found
    }

    pub fn get_by_attr(
        &self,
        attributes_name: &str,
        attributes_value: &str,
    ) -> Option<&ElementNode> {
        for node in &self.children {
            if let Some(found) = search_element_by_attr(node, attributes_name, attributes_value) {
                return Some(found);
            }
        }
        None
    }

    pub fn get_all_by_attr(
        &self,
        attributes_name: &str,
        attributes_value: &str,
    ) -> Vec<&ElementNode> {
        let mut list_found = vec![];
        for node in &self.children {
            list_found.extend(search_all_element_by_attr(
                node,
                attributes_name,
                attributes_value,
            ));
        }
        list_found
    }
}