rewrite
This commit is contained in:
parent
fad24c4b9b
commit
9f8bc315a7
@ -1,3 +1,7 @@
|
||||
[[bin]]
|
||||
name = "navka-client"
|
||||
path = "src/main.rs"
|
||||
|
||||
[package]
|
||||
name = "navka_client"
|
||||
version = "0.3.0"
|
||||
|
||||
@ -43,7 +43,10 @@ impl NavkaClientApp {
|
||||
pub async fn run(&mut self) -> Result<()> {
|
||||
/* detach the aggregator before spawn so `self` is not moved */
|
||||
let aggregator = self.aggregator.take().expect("InputAggregator present");
|
||||
let agg_task = tokio::spawn(async move { aggregator.run().await });
|
||||
let agg_task = tokio::spawn(async move {
|
||||
let mut agg = aggregator;
|
||||
agg.run().await
|
||||
});
|
||||
|
||||
/* two networking tasks */
|
||||
let kbd_loop = self.stream_loop_keyboard();
|
||||
|
||||
@ -24,8 +24,7 @@ impl KeyboardAggregator {
|
||||
|
||||
pub fn process_events(&mut self) {
|
||||
// --- first fetch, then log (avoids aliasing borrow) ---
|
||||
let result = self.dev.fetch_events();
|
||||
let events: Vec<InputEvent> = match result {
|
||||
let events: Vec<InputEvent> = match self.dev.fetch_events() {
|
||||
Ok(it) => it.collect(),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => return,
|
||||
Err(e) => { if self.dev_mode { error!("read error: {e}"); } return }
|
||||
|
||||
@ -26,8 +26,7 @@ impl MouseAggregator {
|
||||
#[inline] fn slog(&self, f: impl FnOnce()) { if self.dev_mode { f() } }
|
||||
|
||||
pub fn process_events(&mut self) {
|
||||
let result = self.dev.fetch_events();
|
||||
let evts: Vec<InputEvent> = match result {
|
||||
let evts: Vec<InputEvent> = match self.dev.fetch_events() {
|
||||
Ok(it) => it.collect(),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => return,
|
||||
Err(e) => { if self.dev_mode { error!("mouse read err: {e}"); } return }
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
[[bin]]
|
||||
name = "navka-common"
|
||||
path = "build.rs"
|
||||
|
||||
[package]
|
||||
name = "navka_common"
|
||||
version = "0.1.0"
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
[[bin]]
|
||||
name = "navka-server"
|
||||
path = "src/main.rs"
|
||||
|
||||
[package]
|
||||
name = "navka_server"
|
||||
version = "0.2.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user