mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-30 16:40:52 +03:00
major update: - remove threading overhead by resorting to an event driven design with mio as a backend for epoll - Clients can now have an arbitrary amount of ip adresses and lan-mouse will automatically choose the correct one - -> seemless switching between ethernet and wifi - cli frontend + frontend adapter for future frontends
59 lines
1.1 KiB
Rust
59 lines
1.1 KiB
Rust
use std::vec::Drain;
|
|
|
|
use mio::{Token, Registry};
|
|
use mio::event::Source;
|
|
use std::io::Result;
|
|
|
|
use crate::{
|
|
client::{ClientHandle, ClientEvent},
|
|
event::Event,
|
|
producer::EventProducer,
|
|
};
|
|
|
|
pub struct WindowsProducer {
|
|
pending_events: Vec<(ClientHandle, Event)>,
|
|
}
|
|
|
|
impl Source for WindowsProducer {
|
|
fn register(
|
|
&mut self,
|
|
_registry: &Registry,
|
|
_token: Token,
|
|
_interests: mio::Interest,
|
|
) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
|
|
fn reregister(
|
|
&mut self,
|
|
_registry: &Registry,
|
|
_token: Token,
|
|
_interests: mio::Interest,
|
|
) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
|
|
fn deregister(&mut self, _registry: &Registry) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
|
|
impl EventProducer for WindowsProducer {
|
|
fn notify(&mut self, _: ClientEvent) { }
|
|
|
|
fn read_events(&mut self) -> Drain<(ClientHandle, Event)> {
|
|
self.pending_events.drain(..)
|
|
}
|
|
|
|
fn release(&mut self) { }
|
|
}
|
|
|
|
impl WindowsProducer {
|
|
pub(crate) fn new() -> Self {
|
|
Self {
|
|
pending_events: vec![],
|
|
}
|
|
}
|
|
}
|