Move OsdArgs to shared crate popcorn-proto

- Avoid duplication
- Improve extensibility
This commit is contained in:
Candifloss 2025-12-31 11:39:17 +05:30
parent 13fe01a7d9
commit 8959cce9f9
8 changed files with 26 additions and 15 deletions

View File

@ -4,6 +4,7 @@ members = [
"crates/popcorn",
"crates/popcorn-d",
"crates/popcorn-conf",
"crates/popcorn-proto",
]
[profile.release]

View File

@ -20,6 +20,7 @@ slint = { version = "1.14.1", default-features = false, features = ["backend-win
toml = "0.9.8"
popcorn-conf = { path = "../popcorn-conf" }
serde = { version = "1.0.228", features = ["derive"] }
popcorn-proto = { path = "../popcorn-proto" }
[build-dependencies]
slint-build = "1.14.1"

View File

@ -1,4 +1,5 @@
use popcorn_conf::PopcornConfig;
use popcorn_proto::OsdArgs;
use i_slint_backend_winit::{
Backend,
@ -22,12 +23,6 @@ fn parse_hex_color(s: &str) -> Result<Color, String> {
}
}
struct OsdArgs {
value: Option<u8>,
icon: Option<String>,
color: Option<String>,
}
pub struct OsdUi {
ui: OSDpopup,
}

View File

@ -0,0 +1,7 @@
[package]
name = "popcorn-proto"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = { version = "1.0.228", features = ["derive"] }

View File

@ -0,0 +1,10 @@
use serde::{Deserialize, Serialize};
// Protocol stuff for IPC comm
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OsdArgs {
pub value: Option<u8>,
pub icon: Option<String>,
pub color: Option<String>,
}

View File

@ -13,3 +13,4 @@ license = "GPL-3+"
[dependencies]
clap = { version = "4.5.53", features = ["derive"] }
popcorn-proto = { path = "../popcorn-proto" }

View File

@ -1,4 +1,5 @@
use clap::{Parser, ValueHint};
use popcorn_proto::OsdArgs;
#[derive(Parser, Debug)]
#[command(
@ -37,12 +38,6 @@ pub struct CliArgs {
pub color: Option<String>,
}
pub struct OsdArgs {
pub value: Option<u8>,
pub icon: Option<String>,
pub color: Option<String>,
}
impl From<CliArgs> for OsdArgs {
fn from(c: CliArgs) -> Self {
Self {

View File

@ -1,6 +1,7 @@
mod args;
use args::{CliArgs, OsdArgs};
use args::CliArgs;
use popcorn_proto::OsdArgs;
use clap::Parser;
fn main() {