feat: Support for screenshot annotate on rust (#706)
Co-authored-by: hidezhao <hidezhao@tencent.com>
This commit is contained in:
@@ -47,10 +47,47 @@ impl RefMap {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn add_selector(
|
||||
&mut self,
|
||||
ref_id: String,
|
||||
selector: String,
|
||||
role: &str,
|
||||
name: &str,
|
||||
nth: Option<usize>,
|
||||
) {
|
||||
self.map.insert(
|
||||
ref_id,
|
||||
RefEntry {
|
||||
backend_node_id: None,
|
||||
role: role.to_string(),
|
||||
name: name.to_string(),
|
||||
nth,
|
||||
selector: Some(selector),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub fn get(&self, ref_id: &str) -> Option<&RefEntry> {
|
||||
self.map.get(ref_id)
|
||||
}
|
||||
|
||||
pub fn entries_sorted(&self) -> Vec<(String, RefEntry)> {
|
||||
let mut entries = self
|
||||
.map
|
||||
.iter()
|
||||
.map(|(ref_id, entry)| (ref_id.clone(), entry.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
entries.sort_by_key(|(ref_id, _)| {
|
||||
ref_id
|
||||
.strip_prefix('e')
|
||||
.and_then(|n| n.parse::<usize>().ok())
|
||||
.unwrap_or(usize::MAX)
|
||||
});
|
||||
|
||||
entries
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.map.clear();
|
||||
self.next_ref = 1;
|
||||
|
||||
Reference in New Issue
Block a user