pub struct RebindClient { /* private fields */ }Expand description
Async WebSocket client for the Rebind remote access protocol.
All HID write methods are fire-and-forget (synchronous, queue internally). All read methods are async and return typed results.
§Example
use rebind_client::RebindClient;
#[tokio::main]
async fn main() -> rebind_client::Result<()> {
let mut client = RebindClient::connect("ws://127.0.0.1:19561").await?;
client.hid_move(30, -5);
let (x, y) = client.system_mouse().await?;
println!("{x} {y}");
client.close().await;
Ok(())
}Implementations§
Source§impl RebindClient
impl RebindClient
Sourcepub async fn connect(url: &str) -> Result<Self>
pub async fn connect(url: &str) -> Result<Self>
Connect to a Rebind relay. Authenticates if token is non-empty.
pub async fn connect_with_token(url: &str, token: &str) -> Result<Self>
pub async fn connect_with_options( url: &str, token: &str, timeout_ms: u64, ) -> Result<Self>
pub fn hid_down(&self, code: &str)
pub fn hid_up(&self, code: &str)
pub fn hid_press(&self, code: &str, hold_ms: u32)
pub fn hid_type(&self, text: &str)
pub fn hid_move(&self, dx: i32, dy: i32)
pub fn hid_move_to(&self, x: i32, y: i32)
pub fn hid_scroll(&self, delta: i32)
pub async fn screen_pixel(&self, x: i32, y: i32) -> Result<Pixel>
pub async fn screen_resolution(&self) -> Result<Resolution>
pub async fn system_mouse(&self) -> Result<(i32, i32)>
pub async fn system_window(&self) -> Result<WindowInfo>
pub async fn system_time(&self) -> Result<u64>
pub async fn input_keys(&self) -> Result<Vec<String>>
pub async fn input_is_down(&self, code: &str) -> Result<bool>
pub async fn input_modifiers(&self) -> Result<Modifiers>
pub async fn clipboard_get(&self) -> Result<String>
pub async fn clipboard_set(&self, text: &str) -> Result<()>
pub async fn window_list(&self, filter: Option<&str>) -> Result<Vec<WindowInfo>>
pub async fn window_find(&self, title: &str) -> Result<Option<i64>>
pub async fn window_activate(&self, handle: i64) -> Result<()>
pub async fn ping(&self) -> Result<u64>
Sourcepub async fn call(&self, command: &str, args: Value) -> Result<Value>
pub async fn call(&self, command: &str, args: Value) -> Result<Value>
Send any server command and return its reply (without the id), including commands
without a typed method. args must be a JSON object; its t and id
are replaced by command and the correlation id.
let r = client.call("hash.sha256", serde_json::json!({ "data": "hello" })).await?;
println!("{}", r["digest"]);Sourcepub async fn mouse_events(&self) -> Result<UnboundedReceiver<Point>>
pub async fn mouse_events(&self) -> Result<UnboundedReceiver<Point>>
Subscribe to mouse position events. Returns a receiver that yields
Point values until the connection closes. Dropping the receiver
stops delivery locally; the server keeps sending until disconnect.
Sourcepub async fn window_events(&self) -> Result<UnboundedReceiver<WindowInfo>>
pub async fn window_events(&self) -> Result<UnboundedReceiver<WindowInfo>>
Subscribe to window focus change events.
Auto Trait Implementations§
impl !RefUnwindSafe for RebindClient
impl !UnwindSafe for RebindClient
impl Freeze for RebindClient
impl Send for RebindClient
impl Sync for RebindClient
impl Unpin for RebindClient
impl UnsafeUnpin for RebindClient
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