Skip to main content

RebindClient

Struct RebindClient 

Source
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

Source

pub async fn connect(url: &str) -> Result<Self>

Connect to a Rebind relay. Authenticates if token is non-empty.

Source

pub async fn connect_with_token(url: &str, token: &str) -> Result<Self>

Source

pub async fn connect_with_options( url: &str, token: &str, timeout_ms: u64, ) -> Result<Self>

Source

pub async fn close(self)

Close the connection gracefully.

Source

pub fn hid_down(&self, code: &str)

Source

pub fn hid_up(&self, code: &str)

Source

pub fn hid_press(&self, code: &str, hold_ms: u32)

Source

pub fn hid_type(&self, text: &str)

Source

pub fn hid_move(&self, dx: i32, dy: i32)

Source

pub fn hid_move_to(&self, x: i32, y: i32)

Source

pub fn hid_scroll(&self, delta: i32)

Source

pub async fn screen_pixel(&self, x: i32, y: i32) -> Result<Pixel>

Source

pub async fn screen_resolution(&self) -> Result<Resolution>

Source

pub async fn system_mouse(&self) -> Result<(i32, i32)>

Source

pub async fn system_window(&self) -> Result<WindowInfo>

Source

pub async fn system_time(&self) -> Result<u64>

Source

pub async fn input_keys(&self) -> Result<Vec<String>>

Source

pub async fn input_is_down(&self, code: &str) -> Result<bool>

Source

pub async fn input_modifiers(&self) -> Result<Modifiers>

Source

pub async fn clipboard_get(&self) -> Result<String>

Source

pub async fn clipboard_set(&self, text: &str) -> Result<()>

Source

pub async fn window_list(&self, filter: Option<&str>) -> Result<Vec<WindowInfo>>

Source

pub async fn window_find(&self, title: &str) -> Result<Option<i64>>

Source

pub async fn window_activate(&self, handle: i64) -> Result<()>

Source

pub async fn ping(&self) -> Result<u64>

Source

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"]);
Source

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.

Source

pub async fn window_events(&self) -> Result<UnboundedReceiver<WindowInfo>>

Subscribe to window focus change events.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V