Skip to content

Commit f5e5480

Browse files
committed
refactor: using built in notifs instead of tracing
1 parent 62578d0 commit f5e5480

12 files changed

+68
-222
lines changed

Cargo.lock

+1-152
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ terminal-light = "1"
2626
anyhow = "1"
2727
iwdrs = "0.1"
2828
chrono = "0.4"
29-
tracing = "0.1"
30-
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
31-
tracing-error = "0.2"
29+
libc = "0.2"
3230

3331
[profile.release]
3432
strip = true
33+
lto = "fat"

src/access_point.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::sync::{atomic::AtomicBool, Arc};
22

3-
use anyhow::Result;
4-
53
use iwdrs::session::Session;
64
use tokio::sync::mpsc::UnboundedSender;
75

@@ -43,7 +41,7 @@ pub struct AccessPoint {
4341
}
4442

4543
impl AccessPoint {
46-
pub async fn new(session: Arc<Session>) -> Result<Self> {
44+
pub async fn new(session: Arc<Session>) -> AppResult<Self> {
4745
let iwd_access_point = session.access_point().unwrap();
4846
let iwd_access_point_diagnotic = session.access_point_diagnostic();
4947

@@ -208,7 +206,7 @@ impl AccessPoint {
208206
frame.render_widget(psk_input, psk_input_area);
209207
}
210208

211-
pub async fn refresh(&mut self) -> Result<()> {
209+
pub async fn refresh(&mut self) -> AppResult<()> {
212210
let iwd_access_point = self.session.access_point().unwrap();
213211
let iwd_access_point_diagnotic = self.session.access_point_diagnostic();
214212

src/adapter.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::Arc;
22

3-
use anyhow::{Context, Result};
3+
use anyhow::Context;
44

55
use iwdrs::{adapter::Adapter as iwdAdapter, session::Session};
66
use ratatui::{
@@ -10,10 +10,12 @@ use ratatui::{
1010
widgets::{Block, BorderType, Borders, Cell, Clear, List, Padding, Row, Table, TableState},
1111
Frame,
1212
};
13+
use tokio::sync::mpsc::UnboundedSender;
1314

1415
use crate::{
15-
app::{ColorMode, FocusedBlock},
16+
app::{AppResult, ColorMode, FocusedBlock},
1617
device::Device,
18+
event::Event,
1719
};
1820

1921
#[derive(Debug, Clone)]
@@ -28,15 +30,15 @@ pub struct Adapter {
2830
}
2931

3032
impl Adapter {
31-
pub async fn new(session: Arc<Session>) -> Result<Self> {
33+
pub async fn new(session: Arc<Session>, sender: UnboundedSender<Event>) -> AppResult<Self> {
3234
let adapter = session.adapter().context("No adapter found")?;
3335

3436
let is_powered = adapter.is_powered().await?;
3537
let name = adapter.name().await?;
3638
let model = adapter.model().await.ok();
3739
let vendor = adapter.vendor().await.ok();
3840
let supported_modes = adapter.supported_modes().await?;
39-
let device = Device::new(session.clone()).await?;
41+
let device = Device::new(session.clone(), sender).await?;
4042

4143
Ok(Self {
4244
adapter,
@@ -49,9 +51,9 @@ impl Adapter {
4951
})
5052
}
5153

52-
pub async fn refresh(&mut self) -> Result<()> {
54+
pub async fn refresh(&mut self, sender: UnboundedSender<Event>) -> AppResult<()> {
5355
self.is_powered = self.adapter.is_powered().await?;
54-
self.device.refresh().await?;
56+
self.device.refresh(sender).await?;
5557
Ok(())
5658
}
5759

0 commit comments

Comments
 (0)