makcu-rs

Crates.iomakcu-rs
lib.rsmakcu-rs
version0.1.1
created_at2025-07-24 14:43:22.77415+00
updated_at2025-07-26 08:19:38.115285+00
descriptionFast and modular communication interface using serial ports, built with async-first design in Rust.
homepagehttps://github.com/whatzwastaken/makcu-rs
repositoryhttps://github.com/whatzwastaken/makcu-rs
max_upload_size
id1766146
size57,893
whatz (whatzwastaken)

documentation

README

makcu-rs

Fast and modular communication interface over serial ports. Built with performance and async-first in mind.

Crates.io Docs.rs License Build


FASTEST EVER MAKCU LIB

🚦 Performance Comparison

Operation makcu-py-lib v2.0 makcu-cpp makcu-rs (avg_us) Evaluation
Mouse Move 2000 Β΅s 70 Β΅s 0.0 Β΅s βœ… Best
Click 1000–2000 Β΅s 160 Β΅s 0.1 Β΅s βœ… Best
Press / Release ~1000 Β΅s 55–100 Β΅s 0.1 Β΅s / 0.0 Β΅s βœ… Best
Wheel Scroll 1000–2000 Β΅s 48 Β΅s 0.0 Β΅s βœ… Best
Batch (9 ops) 3000 Β΅s <100 Β΅s 0.5 Β΅s βœ… Best
Async (5 ops) 2000 Β΅s 200 Β΅s ❌ No data ❓ Needs testing
Connect ~800 Β΅s β€” 860.3 Β΅s ⚠️ Acceptable

Features

  • βœ… Fast and lightweight sync/async communication via serialport and tokio-serial
  • 🧠 Built-in command tracking with optional response timeout
  • πŸ”§ Mouse movement, button presses, scroll wheel, and lock state support
  • πŸ§ͺ Optional mock serial interface for testing (mockserial feature)
  • πŸ“ˆ Optional built-in performance profiler (profile feature)
  • 🧡 Thread-safe, lock-free write queue (via crossbeam-channel)
  • πŸ”‹ Minimal dependencies & portable

πŸ“¦ Installation

Add this to your Cargo.toml:

[dependencies]
makcu-rs = "0.1"

Or with optional features:

makcu-rs = { version = "0.1", features = ["async", "mockserial", "profile"] }

πŸš€ Quick Start

Sync (threaded) example

use makcu_rs::{Device, MouseButton};
use std::time::Duration;

fn main() -> anyhow::Result<()> {
    let dev = Device::new("/dev/ttyUSB0", 115200, Duration::from_millis(100));
    dev.connect()?;

    dev.move_rel(100, 0)?;
    dev.click(MouseButton::Left)?;
    dev.wheel(-2)?;

    dev.disconnect();
    Ok(())
}

Async version

#[tokio::main]
async fn main() -> std::io::Result<()> {
    use makcu_rs::{DeviceAsync, MouseButton};

    let dev = DeviceAsync::new("/dev/ttyUSB0", 115200).await?;

    dev.move_rel(50, 0).await?;
    dev.click(MouseButton::Right).await?;
    dev.wheel(1).await?;

    Ok(())
}

🧰 Features

Feature Description
async Enables tokio-based async interface
profile Built-in performance statistics collection
mockserial Fake serial port for unit testing

Enable with:

cargo build --features "profile mockserial"

πŸ”Ž Tracked Commands

Send a command and wait for a response with a timeout:

let response = dev.set_serial("ABC123")?;
println!("Response: {response}");

πŸ”„ Batch Commands

dev.batch()
    .move_rel(100, 20)
    .click(MouseButton::Left)
    .wheel(-1)
    .run()?;

πŸ“Š Profiler (Optional)

If the profile feature is enabled, collect per-operation timing:

let stats = makcu_rs::Device::profiler_stats();
dbg!(stats);

πŸ§ͺ Testing with Mock Serial

To simulate serial behavior during development:

[features]
mockserial = []

πŸ“š Documentation


πŸͺͺ License

Licensed under either of:

  • MIT License
  • Apache License 2.0

πŸ‡·πŸ‡Ί makcu-rs

Быстрый ΠΈ ΠΌΠΎΠ΄ΡƒΠ»ΡŒΠ½Ρ‹ΠΉ интСрфСйс Ρ€Π°Π±ΠΎΡ‚Ρ‹ с COM-ΠΏΠΎΡ€Ρ‚Π°ΠΌΠΈ. Π‘ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΎΠΉ Ρ‚Ρ€Π΅ΠΊΠΈΠ½Π³Π°, асинхронности ΠΈ ΠΏΠ°ΠΊΠ΅Ρ‚Π½Ρ‹Ρ… ΠΊΠΎΠΌΠ°Π½Π΄.


ΠžΡΠ½ΠΎΠ²Π½Ρ‹Π΅ возмоТности

  • ✨ ΠŸΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° ΠΊΠ°ΠΊ синхронного, Ρ‚Π°ΠΊ ΠΈ асинхронного (tokio) Ρ€Π΅ΠΆΠΈΠΌΠ°
  • ⏱ ΠžΡ‚ΠΏΡ€Π°Π²ΠΊΠ° ΠΊΠΎΠΌΠ°Π½Π΄ с ΠΎΠΆΠΈΠ΄Π°Π½ΠΈΠ΅ΠΌ ΠΎΡ‚Π²Π΅Ρ‚Π° (с Ρ‚Π°ΠΉΠΌΠ°ΡƒΡ‚ΠΎΠΌ)
  • πŸ”˜ Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΌΡ‹ΡˆΠΈ, ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ, ΠΏΡ€ΠΎΠΊΡ€ΡƒΡ‚ΠΊΠΎΠΉ
  • πŸ“¦ ΠŸΠ°ΠΊΠ΅Ρ‚Π½Π°Ρ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΊΠ° ΠΊΠΎΠΌΠ°Π½Π΄ (batch API)
  • πŸ§ͺ ВСстируСмый mockserial Ρ€Π΅ΠΆΠΈΠΌ
  • πŸ” ВстроСнный ΠΏΡ€ΠΎΡ„Π°ΠΉΠ»Π΅Ρ€ (ΠΎΠΏΡ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½ΠΎ)

Быстрый ΠΏΡ€ΠΈΠΌΠ΅Ρ€ (синхронный)

let dev = Device::new("COM3", 115200, Duration::from_millis(100));
dev.connect()?;
dev.click(MouseButton::Left)?;
dev.disconnect();

Быстрый ΠΏΡ€ΠΈΠΌΠ΅Ρ€ (асинхронный)

let dev = DeviceAsync::new("COM3", 115200).await?;
dev.press(MouseButton::Middle).await?;

ЛицСнзия

ΠŸΡ€ΠΎΠ΅ΠΊΡ‚ распространяСтся ΠΏΠΎΠ΄ MIT ΠΈΠ»ΠΈ Apache 2.0 Π»ΠΈΡ†Π΅Π½Π·ΠΈΠ΅ΠΉ Π½Π° ваш Π²Ρ‹Π±ΠΎΡ€.


🀝 ΠŸΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ°

Π‘ΠΎΠ·Π΄Π°Π²Π°ΠΉΡ‚Π΅ issue Π½Π° GitHub ΠΈΠ»ΠΈ ΠΏΠΈΡˆΠΈΡ‚Π΅ Π°Π²Ρ‚ΠΎΡ€Ρƒ: @whatzwasthere (TG/GitHub)


πŸ“¦ Cargo Features Summary

Feature ОписаниС
async Π’ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ tokio-совмСстимый API
profile Π’ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ встроСнный ΠΏΡ€ΠΎΡ„Π°ΠΉΠ»Π΅Ρ€ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΉ
mockserial Π€Π΅ΠΉΠΊΠΎΠ²Ρ‹ΠΉ COM-ΠΏΠΎΡ€Ρ‚ (для тСстирования)

πŸ’‘ makcu-rs ΠΏΠΎΠΌΠΎΠ³Π°Π΅Ρ‚ ΡƒΠ΄ΠΎΠ±Π½ΠΎ ΡƒΠΏΡ€Π°Π²Π»ΡΡ‚ΡŒ внСшними устройствами (ΠΌΡ‹ΡˆΠΈ, Ρ‚Ρ€Π΅ΠΊΠΏΠ°Π΄Ρ‹, манипуляторы) Ρ‡Π΅Ρ€Π΅Π· COM-ΠΏΠΎΡ€Ρ‚, минимизируя Π·Π°Π΄Π΅Ρ€ΠΆΠΊΠΈ ΠΈ ΠΏΠΎΠ²Ρ‹ΡˆΠ°Ρ Π½Π°Π΄Ρ‘ΠΆΠ½ΠΎΡΡ‚ΡŒ взаимодСйствия.

Commit count: 0

cargo fmt