Skip to content

Commit

Permalink
refactor: rename provider-related files (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger authored Sep 17, 2024
1 parent e5e0959 commit 82f29f2
Show file tree
Hide file tree
Showing 39 changed files with 200 additions and 249 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Context;
use serde::{Deserialize, Serialize};
use starship_battery::{
units::{
electric_potential::volt, power::watt, ratio::percent,
Expand All @@ -7,9 +8,28 @@ use starship_battery::{
Manager, State,
};

use super::{BatteryOutput, BatteryProviderConfig};
use crate::{impl_interval_provider, providers::ProviderOutput};

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct BatteryProviderConfig {
pub refresh_interval: u64,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BatteryOutput {
pub charge_percent: f32,
pub health_percent: f32,
pub state: String,
pub is_charging: bool,
pub time_till_full: Option<f32>,
pub time_till_empty: Option<f32>,
pub power_consumption: f32,
pub voltage: f32,
pub cycle_count: Option<u32>,
}

pub struct BatteryProvider {
config: BatteryProviderConfig,
}
Expand Down
7 changes: 0 additions & 7 deletions packages/desktop/src/providers/battery/config.rs

This file was deleted.

8 changes: 2 additions & 6 deletions packages/desktop/src/providers/battery/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
mod config;
mod provider;
mod variables;
mod battery_provider;

pub use config::*;
pub use provider::*;
pub use variables::*;
pub use battery_provider::*;
15 changes: 0 additions & 15 deletions packages/desktop/src/providers/battery/variables.rs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/desktop/src/providers/cpu/config.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
use std::sync::Arc;

use serde::{Deserialize, Serialize};
use sysinfo::System;
use tokio::sync::Mutex;

use super::{CpuOutput, CpuProviderConfig};
use crate::{impl_interval_provider, providers::ProviderOutput};

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CpuProviderConfig {
pub refresh_interval: u64,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CpuOutput {
pub frequency: u64,
pub usage: f32,
pub logical_core_count: usize,
pub physical_core_count: usize,
pub vendor: String,
}

pub struct CpuProvider {
config: CpuProviderConfig,
sysinfo: Arc<Mutex<System>>,
Expand Down
8 changes: 2 additions & 6 deletions packages/desktop/src/providers/cpu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
mod config;
mod provider;
mod variables;
mod cpu_provider;

pub use config::*;
pub use provider::*;
pub use variables::*;
pub use cpu_provider::*;
11 changes: 0 additions & 11 deletions packages/desktop/src/providers/cpu/variables.rs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/desktop/src/providers/host/config.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
use serde::{Deserialize, Serialize};
use sysinfo::System;

use super::{HostOutput, HostProviderConfig};
use crate::{impl_interval_provider, providers::ProviderOutput};

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct HostProviderConfig {
pub refresh_interval: u64,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HostOutput {
pub hostname: Option<String>,
pub os_name: Option<String>,
pub os_version: Option<String>,
pub friendly_os_version: Option<String>,
pub boot_time: u64,
pub uptime: u64,
}

pub struct HostProvider {
config: HostProviderConfig,
}
Expand Down
8 changes: 2 additions & 6 deletions packages/desktop/src/providers/host/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
mod config;
mod provider;
mod variables;
mod host_provider;

pub use config::*;
pub use provider::*;
pub use variables::*;
pub use host_provider::*;
12 changes: 0 additions & 12 deletions packages/desktop/src/providers/host/variables.rs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/desktop/src/providers/ip/config.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use anyhow::Context;
use reqwest::Client;
use serde::{Deserialize, Serialize};

use super::{ipinfo_res::IpinfoRes, IpOutput, IpProviderConfig};
use super::ipinfo_res::IpinfoRes;
use crate::{impl_interval_provider, providers::ProviderOutput};

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct IpProviderConfig {
pub refresh_interval: u64,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct IpOutput {
pub address: String,
pub approx_city: String,
pub approx_country: String,
pub approx_latitude: f32,
pub approx_longitude: f32,
}

pub struct IpProvider {
config: IpProviderConfig,
http_client: Client,
Expand Down
8 changes: 2 additions & 6 deletions packages/desktop/src/providers/ip/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
mod config;
mod ip_provider;
mod ipinfo_res;
mod provider;
mod variables;

pub use config::*;
pub use provider::*;
pub use variables::*;
pub use ip_provider::*;
11 changes: 0 additions & 11 deletions packages/desktop/src/providers/ip/variables.rs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/desktop/src/providers/keyboard/config.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::bail;
use serde::{Deserialize, Serialize};
use windows::Win32::{
Globalization::{LCIDToLocaleName, LOCALE_ALLOW_NEUTRAL_NAMES},
System::SystemServices::LOCALE_NAME_MAX_LENGTH,
Expand All @@ -8,9 +9,20 @@ use windows::Win32::{
},
};

use super::{KeyboardOutput, KeyboardProviderConfig};
use crate::{impl_interval_provider, providers::ProviderOutput};

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct KeyboardProviderConfig {
pub refresh_interval: u64,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct KeyboardOutput {
pub layout: String,
}

pub struct KeyboardProvider {
config: KeyboardProviderConfig,
}
Expand Down
8 changes: 2 additions & 6 deletions packages/desktop/src/providers/keyboard/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
mod config;
mod provider;
mod variables;
mod keyboard_provider;

pub use config::*;
pub use provider::*;
pub use variables::*;
pub use keyboard_provider::*;
7 changes: 0 additions & 7 deletions packages/desktop/src/providers/keyboard/variables.rs

This file was deleted.

5 changes: 0 additions & 5 deletions packages/desktop/src/providers/komorebi/config.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ use async_trait::async_trait;
use komorebi_client::{
Container, Monitor, SocketMessage, Window, Workspace,
};
use serde::{Deserialize, Serialize};
use tokio::{sync::mpsc::Sender, time};
use tracing::debug;

use super::{
KomorebiContainer, KomorebiLayout, KomorebiLayoutFlip, KomorebiMonitor,
KomorebiOutput, KomorebiProviderConfig, KomorebiWindow,
KomorebiWorkspace,
KomorebiWindow, KomorebiWorkspace,
};
use crate::providers::{Provider, ProviderOutput, ProviderResult};

const SOCKET_NAME: &str = "zebar.sock";

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct KomorebiProviderConfig {}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct KomorebiOutput {
pub all_monitors: Vec<KomorebiMonitor>,
pub focused_monitor_index: usize,
}

pub struct KomorebiProvider {
_config: KomorebiProviderConfig,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
use komorebi_client::{Axis, DefaultLayout, Layout, Rect};
use serde::Serialize;

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct KomorebiOutput {
pub all_monitors: Vec<KomorebiMonitor>,
pub focused_monitor_index: usize,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct KomorebiMonitor {
Expand Down
10 changes: 4 additions & 6 deletions packages/desktop/src/providers/komorebi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mod config;
mod provider;
mod variables;
mod komorebi_provider;
mod komorebi_res;

pub use config::*;
pub use provider::*;
pub use variables::*;
pub use komorebi_provider::*;
pub use komorebi_res::*;
7 changes: 0 additions & 7 deletions packages/desktop/src/providers/memory/config.rs

This file was deleted.

Loading

0 comments on commit 82f29f2

Please sign in to comment.