pub enum Selector { /// A CSS query selector of the element Query(String), /// this element itself This, /// closest which will find the closest ancestor element or itself, that matches the given CSS selector. Closest(String), /// find which will find the first child descendant element that matches the given CSS selector Find(String), /// next which resolves to element.nextElementSibling Next, /// next which will scan the DOM forward for the first element that matches the given CSS selector. NextQuery(String), /// previous which resolves to element.previousElementSibling Previous, /// previous which will scan the DOM backwards for the first element that matches the given CSS selector. PreviousQuery(String), } impl Selector { #[must_use] pub fn to_value(&self) -> String { match self { Self::Query(query) => query.clone(), Self::This => "this".to_owned(), Self::Closest(css) => format!("closest {css}"), Self::Find(css) => format!("find {css}"), Self::Next => "next".to_owned(), Self::NextQuery(css) => format!("next {css}"), Self::Previous => "previous".to_owned(), Self::PreviousQuery(css) => format!("previous {css}"), } } }