pub trait SliderTab {
// Required methods
fn sl_run_js(&self, js: &str) -> impl Future<Output = Result<Value>>;
fn sl_ele_screenshot(
&self,
css_selector: &str,
) -> impl Future<Output = Result<Vec<u8>>>;
fn sl_ele_click(&self, css_selector: &str) -> impl Future<Output = ()>;
fn sl_mouse_move(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
fn sl_mouse_down(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
fn sl_mouse_drag(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
fn sl_mouse_drag_fast(&self, x: f64, y: f64) -> Result<()>;
fn sl_mouse_up(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
}Available on crate feature
slider only.Expand description
滑块求解所需的后端原语(camoufox Tab 与 cdp ChromiumTab 都实现)。
核心求解逻辑(slider_gap/solve_slider 等)只依赖这几个原语,故与具体后端解耦;
想接入自定义后端,实现本 trait 即可复用整套滑块能力。定位器一律用 css:<sel> 前缀,方法内部
只传裸 CSS 选择器给 sl_ele_*,由实现自行补前缀。
Required Methods§
Sourcefn sl_run_js(&self, js: &str) -> impl Future<Output = Result<Value>>
fn sl_run_js(&self, js: &str) -> impl Future<Output = Result<Value>>
在页面里执行 JS 表达式并回传其值(缺口像素重活都在此)。
Sourcefn sl_ele_screenshot(
&self,
css_selector: &str,
) -> impl Future<Output = Result<Vec<u8>>>
fn sl_ele_screenshot( &self, css_selector: &str, ) -> impl Future<Output = Result<Vec<u8>>>
浏览器级截图某元素(CSS 选择器,taint-proof;顶象拼图跨域 taint 时用)。
Sourcefn sl_ele_click(&self, css_selector: &str) -> impl Future<Output = ()>
fn sl_ele_click(&self, css_selector: &str) -> impl Future<Output = ()>
best-effort 点击某元素(CSS 选择器;找不到则静默)。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".