pub struct ElementFingerprint {
pub tag: String,
pub classes: Vec<String>,
pub attr_names: Vec<String>,
pub depth: u32,
}Expand description
A structural snapshot of a DOM element for similarity comparison.
Serialisable so callers can persist fingerprints across sessions.
§Example
use stygian_browser::similarity::ElementFingerprint;
let fp = ElementFingerprint {
tag: "div".to_string(),
classes: vec!["card".to_string(), "highlighted".to_string()],
attr_names: vec!["data-id".to_string()],
depth: 3,
};
let json = serde_json::to_string(&fp).unwrap();
let back: ElementFingerprint = serde_json::from_str(&json).unwrap();
assert_eq!(fp.tag, back.tag);Fields§
§tag: StringLower-case tag name (e.g. "div", "a").
classes: Vec<String>Sorted CSS class list (excluding the empty string).
attr_names: Vec<String>Sorted attribute names present on the element, excluding "class" and
"id".
depth: u32Distance from <body> in the DOM tree (direct children of <body>
have depth 0).
Trait Implementations§
Source§impl Clone for ElementFingerprint
impl Clone for ElementFingerprint
Source§fn clone(&self) -> ElementFingerprint
fn clone(&self) -> ElementFingerprint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ElementFingerprint
impl Debug for ElementFingerprint
Source§impl<'de> Deserialize<'de> for ElementFingerprint
impl<'de> Deserialize<'de> for ElementFingerprint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ElementFingerprint
impl PartialEq for ElementFingerprint
Source§impl Serialize for ElementFingerprint
impl Serialize for ElementFingerprint
impl Eq for ElementFingerprint
impl StructuralPartialEq for ElementFingerprint
Auto Trait Implementations§
impl Freeze for ElementFingerprint
impl RefUnwindSafe for ElementFingerprint
impl Send for ElementFingerprint
impl Sync for ElementFingerprint
impl Unpin for ElementFingerprint
impl UnsafeUnpin for ElementFingerprint
impl UnwindSafe for ElementFingerprint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.