Struct parsercher::dom::Dom [−][src]
pub struct Dom { pub dom_type: DomType, // some fields omitted }
Expand description
A structure that represents the parsing result of a tag document.
Fields
dom_type: DomType
Expand description
Type of Dom structure
Implementations
impl Dom
[src]
impl Dom
[src]pub fn new_root() -> Dom
[src]
pub fn new_root() -> Dom
[src]Create the new root dom.
The root dom has a Tag structure whose name is root.
pub fn get_tag(&self) -> Option<&Tag>
[src]
pub fn get_tag(&self) -> Option<&Tag>
[src]Returns the Tag structure.
If it does not have a Tag structure, it returns None
.
pub fn get_text(&self) -> Option<&Text>
[src]
pub fn get_text(&self) -> Option<&Text>
[src]Returns the Text structure.
If it does not have a Text structure, it returns None
.
pub fn set_comment(&mut self, comment: Comment)
[src]
pub fn set_comment(&mut self, comment: Comment)
[src]pub fn get_comment(&self) -> Option<&Comment>
[src]
pub fn get_comment(&self) -> Option<&Comment>
[src]Returns the Comment structure.
If it does not have a Comment structure, it returns None
.
pub fn get_children(&self) -> Option<&Vec<Box<Dom>>>
[src]
pub fn get_children(&self) -> Option<&Vec<Box<Dom>>>
[src]Returns child Dom structures as Vec.
If it does not have children, it returns None
.
pub fn p_implies_q(p: &Dom, q: &Dom) -> bool
[src]
pub fn p_implies_q(p: &Dom, q: &Dom) -> bool
[src]Returns true if p is a sufficient condition for q.
p => q
Examples
use parsercher::dom::DomType; use parsercher::dom::Dom; use parsercher::dom::Tag; let mut p = Dom::new(DomType::Tag); let mut tag = Tag::new("h1"); tag.set_attr("class", "target"); p.set_tag(tag); let mut q = Dom::new(DomType::Tag); let mut tag = Tag::new("h1"); tag.set_attr("id", "q"); tag.set_attr("class", "target"); q.set_tag(tag); assert_eq!(Dom::p_implies_q(&p, &q), true); let mut q = Dom::new(DomType::Tag); let mut tag = Tag::new("h1"); tag.set_attr("id", "q"); q.set_tag(tag); assert_eq!(Dom::p_implies_q(&p, &q), false);
pub fn p_implies_q_tree(p: &Dom, q: &Dom) -> bool
[src]
pub fn p_implies_q_tree(p: &Dom, q: &Dom) -> bool
[src]Returns true if p is a sufficient condition for q.
Compare the entire tree. p => q
Examples
use parsercher; use parsercher::dom::Dom; // p let p = r#" <h1> <div></div> <ul> <li></li> </ul> </h1> "#; let p_dom = parsercher::parse(&p).unwrap(); // Remove `root`dom of p_dom let p_dom = p_dom.get_children().unwrap().get(0).unwrap(); // q let q = r#" <h1> <div id="divId"></div> <ul> <li></li> </ul> <span></span> </h1> "#; let q_dom = parsercher::parse(&q).unwrap(); // Remove `root`dom of p_dom let q_dom = q_dom.get_children().unwrap().get(0).unwrap(); assert_eq!(Dom::p_implies_q_tree(&p_dom, &q_dom), true);
Trait Implementations
impl StructuralPartialEq for Dom
[src]
Auto Trait Implementations
impl RefUnwindSafe for Dom
impl Send for Dom
impl Sync for Dom
impl Unpin for Dom
impl UnwindSafe for Dom
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more