Colpetto
Colpetto is a modern Rust library that provides asynchronous bindings for libinput, enabling efficient handling of input device events on Linux systems. Built on tokio, it offers a stream-based API that seamlessly integrates with async applications while maintaining low latency and efficient resource usage for real-time operations.
Key Features
Colpetto transforms libinput's traditional callback-based interface into an ergonomic Rust API with:
- Stream-based event handling powered by tokio
- Low-overhead event polling optimized for performance
- Flexible logging system with built-in basic loggers
Examples
Here's a basic example demonstrating event handling using rustix:
use ;
use ;
use StreamExt;
async
For more examples, check out the examples directory:
- Simple: Basic event handling demonstration
- Print Keys: Advanced example with custom logging and keyboard event handling
Comparison with input-rs
While input-rs is an established alternative, Colpetto takes a different approach in several key areas:
Interface Design
Colpetto uses direct function passing for device management, while input-rs employs a trait-based approach:
// Colpetto: Function-based approach with closure support
let mut libinput = new?;
// input-rs: Trait-based approach
;
let mut input = new_with_udev;
Some key Advantages
- Native tokio integration for async/await support
- Stream-based event handling via
event_stream() - Safe handling of non-UTF8 strings using
CStrinstead of implicit panics - Comprehensive event type safety through more exhaustive enum matching
- More robust context lifetime management
License
This project is licensed under the Apache-2.0 License. For more information, please see the LICENSE file.