2 releases
Uses new Rust 2024
| 0.1.1 | Jul 26, 2025 |
|---|---|
| 0.1.0 | Jul 24, 2025 |
#871 in Asynchronous
44 downloads per month
40KB
700 lines
makcu-rs
Fast and modular communication interface over serial ports. Built with performance and async-first in mind.
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
serialportandtokio-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 (
mockserialfeature) - 📈 Optional built-in performance profiler (
profilefeature) - 🧵 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-порт, минимизируя задержки и повышая надёжность взаимодействия.
Dependencies
~6–17MB
~187K SLoC