pub struct SelectorCache { /* private fields */ }Expand description
Self-healing selector cache.
Stores mappings from natural language descriptions to CSS selectors that successfully matched elements. Supports LRU eviction.
§Self-Healing Flow
- User requests action like “click the login button”
- Cache lookup: if cached selector for “login button” exists, try it
- If selector works → action succeeds, update cache timestamp
- If selector fails → invalidate entry, re-query LLM for new selector
- Store new selector in cache for future use
Implementations§
Source§impl SelectorCache
impl SelectorCache
Sourcepub fn with_capacity(max_entries: usize) -> Self
pub fn with_capacity(max_entries: usize) -> Self
Create with specified capacity.
Sourcepub fn get(&mut self, description: &str, domain: Option<&str>) -> Option<&str>
pub fn get(&mut self, description: &str, domain: Option<&str>) -> Option<&str>
Look up a cached selector for an element description.
Optionally filter by domain for site-specific selectors.
Sourcepub fn record_success(
&mut self,
description: &str,
selector: &str,
domain: Option<&str>,
)
pub fn record_success( &mut self, description: &str, selector: &str, domain: Option<&str>, )
Record a successful selector use.
Sourcepub fn record_failure(&mut self, description: &str)
pub fn record_failure(&mut self, description: &str)
Record a selector failure and potentially invalidate.
After 2 consecutive failures, the entry is removed.
Sourcepub fn invalidate(&mut self, description: &str)
pub fn invalidate(&mut self, description: &str)
Invalidate (remove) a cache entry.
Sourcepub fn selectors_for_domain(&self, domain: &str) -> Vec<(&str, &str)>
pub fn selectors_for_domain(&self, domain: &str) -> Vec<(&str, &str)>
Get all cached selectors for a domain.
Sourcepub fn export(&self) -> Vec<SelectorCacheEntry>
pub fn export(&self) -> Vec<SelectorCacheEntry>
Export cache entries (for persistence).
Sourcepub fn import(
&mut self,
entries: impl IntoIterator<Item = (String, SelectorCacheEntry)>,
)
pub fn import( &mut self, entries: impl IntoIterator<Item = (String, SelectorCacheEntry)>, )
Import cache entries (from persistence).
Trait Implementations§
Source§impl Clone for SelectorCache
impl Clone for SelectorCache
Source§fn clone(&self) -> SelectorCache
fn clone(&self) -> SelectorCache
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 SelectorCache
impl Debug for SelectorCache
Auto Trait Implementations§
impl Freeze for SelectorCache
impl RefUnwindSafe for SelectorCache
impl Send for SelectorCache
impl Sync for SelectorCache
impl Unpin for SelectorCache
impl UnwindSafe for SelectorCache
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