schengen 0.2.0

Helper library for building Synergy-compatible clients and servers
Documentation
  • Coverage
  • 68.2%
    208 out of 305 items documented11 out of 95 items with examples
  • Size
  • Source code size: 219.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 20.74 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 39s Average build duration of successful builds.
  • all releases: 39s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • whot

schengen

schengen is a Rust library for building Synergy/Deskflow-compatible clients and servers for mouse and keyboard sharing across multiple computers.

This crate provides the core protocol implementation and high-level APIs for parsing and serializing Synergy/Deskflow protocol messages and building Synergy/Deskflow clients and servers.

The goal is to be able to build a client or server without needing much knowledge of the protocol itself.

This crate is part of the schengen project:

About the Protocol

Schengen implements the Synergy/Deskflow protocol, which is compatible with:

For more details on protocol compatibility, see the crate documentation.

Usage

Add this to your Cargo.toml:

[dependencies]
schengen = "0.1"

Building a Client

use schengen::client::{Builder, ClientEvent};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Builder::new()
        .server_addr("localhost:24801")?
        .name("my-client")
        .dimensions(1920, 1080)
        .connect()
        .await?;

    loop {
        match client.recv_event().await? {
            ClientEvent::CursorEntered { x, y, .. } => {
                println!("Cursor entered at ({}, {})", x, y);
            }
            ClientEvent::CursorLeft => {
                println!("Cursor left");
                break;
            }
            _ => {}
        }
    }

    Ok(())
}

Building a Server

use schengen::server::{Builder, ClientBuilder, Position, ServerEvent};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let laptop = ClientBuilder::new("laptop")
        .position(Position::Left)
        .build();

    let mut server = Builder::new()
        .listen_addr("0.0.0.0:24801")?
        .add_client(laptop)
        .build()
        .await?;

    loop {
        let event = server.recv_event().await?;
        // Handle server events
    }

    Ok(())
}

Working with the Protocol

use schengen::protocol::{Message, parse_message, ProtocolMessage};

// Parse a message from bytes
let data = b"CALV";
let msg = parse_message(data)?;

Building

This is a typical Rust crate. Build with:

$ cargo build
$ cargo test

Documentation

Build the documentation with:

$ cargo doc --open

License

GPLv3 or later