Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Add a hack to share structs (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
satler-git authored Aug 2, 2024
1 parent 57f2bcb commit d1f5357
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
29 changes: 2 additions & 27 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use anyhow::{Context as _, Result, anyhow, bail};

use komorebi_client::{Window, Workspace};
use komorebi_client::{send_query, SocketMessage, State};
use serde::{Deserialize, Serialize};
use tauri::Manager as _;
use tauri::SystemTray;
use tauri::SystemTrayEvent;
Expand Down Expand Up @@ -121,32 +120,8 @@ fn fetch_komorebi_state() -> Result<State> {
// or, you may not running komorebi
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct AsayakeMonitorState {
monitor_index: usize,
focusing_workspace: usize,
workspaces: Vec<WorkspaceForSend>,
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct WorkspaceForSend {}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
enum WorkspaceItem {
Window(WindowForSend),
WindowStack(Vec<WindowForSend>)
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct WindowForSend {
icon: Icon,
accent_color: u32
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct Icon {
base64_icon: String,
}
// HACK: クレートを分割するとimplできないという制約を乗り越えるための方法。醜い
include!("./structs.rs");

impl From<&Workspace> for WorkspaceForSend {
fn from(value: &Workspace) -> Self {
Expand Down
28 changes: 28 additions & 0 deletions src-tauri/src/structs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct AsayakeMonitorState {
monitor_index: usize,
focusing_workspace: usize,
workspaces: Vec<WorkspaceForSend>,
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct WorkspaceForSend {}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
enum WorkspaceItem {
Window(WindowForSend),
WindowStack(Vec<WindowForSend>)
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct WindowForSend {
icon: Icon,
accent_color: u32
}

#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
struct Icon {
base64_icon: String,
}

0 comments on commit d1f5357

Please sign in to comment.