From 387c043367339dd49d71e2bc1e638333fd235ef7 Mon Sep 17 00:00:00 2001 From: fluo10 Date: Wed, 2 Jul 2025 08:32:15 +0900 Subject: [PATCH] Add device subcommand --- examples/desktop/Cargo.toml | 2 + examples/desktop/src/cli.rs | 16 ++++ examples/desktop/src/ipc.rs | 0 examples/desktop/src/main.rs | 2 + examples/desktop/src/message.rs | 0 lazy-supplements-core/src/async_convert.rs | 29 +++++++ lazy-supplements-core/src/config/mod.rs | 2 +- lazy-supplements-core/src/lib.rs | 1 + lazy-supplements-core/src/message.rs | 15 ---- lazy-supplements-core/src/message/mod.rs | 52 ++++++++++++ lazy-supplements-core/src/message/node.rs | 10 +++ lazy-supplements-core/src/p2p/error.rs | 4 + lazy-supplements-core/src/p2p/mod.rs | 1 + .../src/cli/{ => args}/config.rs | 30 +++++-- .../src/cli/args/device.rs | 12 +++ lazy-supplements-desktop/src/cli/args/mod.rs | 7 ++ lazy-supplements-desktop/src/cli/args/peer.rs | 10 +++ .../src/cli/device/add.rs | 23 ++++++ .../src/cli/device/list.rs | 15 ++++ .../src/cli/device/mod.rs | 37 +++++++++ .../src/cli/device/ping.rs | 17 ++++ .../src/cli/device/remove.rs | 17 ++++ .../src/cli/device/scan.rs | 15 ++++ lazy-supplements-desktop/src/cli/logs.rs | 4 + lazy-supplements-desktop/src/cli/mod.rs | 14 ++-- lazy-supplements-desktop/src/cli/node.rs | 81 ------------------- lazy-supplements-desktop/src/config/mod.rs | 25 +++++- lazy-supplements-desktop/src/config/unix.rs | 3 + .../src/ipc/message/mod.rs | 15 +++- 29 files changed, 345 insertions(+), 114 deletions(-) create mode 100644 examples/desktop/src/cli.rs create mode 100644 examples/desktop/src/ipc.rs create mode 100644 examples/desktop/src/message.rs create mode 100644 lazy-supplements-core/src/async_convert.rs delete mode 100644 lazy-supplements-core/src/message.rs create mode 100644 lazy-supplements-core/src/message/mod.rs create mode 100644 lazy-supplements-core/src/message/node.rs create mode 100644 lazy-supplements-core/src/p2p/error.rs rename lazy-supplements-desktop/src/cli/{ => args}/config.rs (50%) create mode 100644 lazy-supplements-desktop/src/cli/args/device.rs create mode 100644 lazy-supplements-desktop/src/cli/args/mod.rs create mode 100644 lazy-supplements-desktop/src/cli/args/peer.rs create mode 100644 lazy-supplements-desktop/src/cli/device/add.rs create mode 100644 lazy-supplements-desktop/src/cli/device/list.rs create mode 100644 lazy-supplements-desktop/src/cli/device/mod.rs create mode 100644 lazy-supplements-desktop/src/cli/device/ping.rs create mode 100644 lazy-supplements-desktop/src/cli/device/remove.rs create mode 100644 lazy-supplements-desktop/src/cli/device/scan.rs create mode 100644 lazy-supplements-desktop/src/cli/logs.rs delete mode 100644 lazy-supplements-desktop/src/cli/node.rs diff --git a/examples/desktop/Cargo.toml b/examples/desktop/Cargo.toml index a8eb816..625c713 100644 --- a/examples/desktop/Cargo.toml +++ b/examples/desktop/Cargo.toml @@ -6,7 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap.workspace = true dioxus.workspace = true +lazy-supplements-desktop.path = "../../lazy-supplements-desktop" lazy-supplements-examples-core.path = "../core" [features] diff --git a/examples/desktop/src/cli.rs b/examples/desktop/src/cli.rs new file mode 100644 index 0000000..7e54520 --- /dev/null +++ b/examples/desktop/src/cli.rs @@ -0,0 +1,16 @@ +use clap::{Parser, Subcommand}; +use lazy_supplements_desktop::cli::*; + +#[derive(Debug, Parser)] +pub struct Cli { + #[command(subcommand)] + command: CliCommand +} + +#[derive(Debug, Subcommand)] +pub enum CliCommand { + Config(ConfigCommandArgs), + Device(DeviceCommandArgs), + Log(LogCommandArgs), + Server(ServerCommandArgs), +} \ No newline at end of file diff --git a/examples/desktop/src/ipc.rs b/examples/desktop/src/ipc.rs new file mode 100644 index 0000000..e69de29 diff --git a/examples/desktop/src/main.rs b/examples/desktop/src/main.rs index e9fdd69..fa3a0e4 100644 --- a/examples/desktop/src/main.rs +++ b/examples/desktop/src/main.rs @@ -1,3 +1,5 @@ +mod cli; +mod ipc; fn main() { dioxus::launch(lazy_supplements_examples_core::ui::plain::App); } diff --git a/examples/desktop/src/message.rs b/examples/desktop/src/message.rs new file mode 100644 index 0000000..e69de29 diff --git a/lazy-supplements-core/src/async_convert.rs b/lazy-supplements-core/src/async_convert.rs new file mode 100644 index 0000000..82227cc --- /dev/null +++ b/lazy-supplements-core/src/async_convert.rs @@ -0,0 +1,29 @@ +pub trait AsyncFrom { + async fn async_from(source: T) -> Self; +} +pub trait AsyncInto { + async fn async_into(self) -> T; +} +impl AsyncInto for U +where T: AsyncFrom { + async fn async_into(self) -> T { + T::async_from(self).await + } +} + +pub trait AsyncTryFrom: Sized { + type Error: Sized; + async fn async_try_from(source: T) -> Result; +} +pub trait AsyncTryInto: Sized{ + type Error: Sized; + async fn async_try_into(self) -> Result; +} + +impl AsyncTryInto for U +where T: AsyncTryFrom { + type Error = >::Error; + async fn async_try_into(self) -> Result { + T::async_try_from(self).await + } +} \ No newline at end of file diff --git a/lazy-supplements-core/src/config/mod.rs b/lazy-supplements-core/src/config/mod.rs index 6e8b7d8..7e2800f 100644 --- a/lazy-supplements-core/src/config/mod.rs +++ b/lazy-supplements-core/src/config/mod.rs @@ -25,7 +25,7 @@ pub trait PartialConfig: Serialize + Sized + DeserializeOwned fn is_empty(&self) -> bool; } -pub trait ConfigRoot: DeserializeOwned + Serialize { +pub trait PartialConfigRoot: DeserializeOwned + Serialize { fn new() -> Self; async fn read_or_create(path: T) -> Result diff --git a/lazy-supplements-core/src/lib.rs b/lazy-supplements-core/src/lib.rs index 9cbbfd8..77422f7 100644 --- a/lazy-supplements-core/src/lib.rs +++ b/lazy-supplements-core/src/lib.rs @@ -1,3 +1,4 @@ +pub mod async_convert; pub mod cache; pub mod config; pub mod data; diff --git a/lazy-supplements-core/src/message.rs b/lazy-supplements-core/src/message.rs deleted file mode 100644 index 5fba819..0000000 --- a/lazy-supplements-core/src/message.rs +++ /dev/null @@ -1,15 +0,0 @@ -use serde::{de::DeserializeOwned, Serialize}; - -pub trait Message: DeserializeOwned + Sized + Serialize { - fn into_writer(&self, writer: W) -> Result<(), ciborium::ser::Error> { - ciborium::into_writer(self, writer) - } - fn into_vec_u8(&self) -> Result, ciborium::ser::Error> { - let mut buf: Vec = Vec::new(); - self.into_writer(&mut buf)?; - Ok(buf) - } - fn from_reader(reader: R) -> Result> { - ciborium::from_reader(reader) - } -} \ No newline at end of file diff --git a/lazy-supplements-core/src/message/mod.rs b/lazy-supplements-core/src/message/mod.rs new file mode 100644 index 0000000..39933eb --- /dev/null +++ b/lazy-supplements-core/src/message/mod.rs @@ -0,0 +1,52 @@ +mod node; +use serde::{de::DeserializeOwned, Serialize}; +use uuid::Uuid; + +use crate::{async_convert::{AsyncTryFrom, AsyncTryInto}, error::Error}; + +pub trait Message: DeserializeOwned + Sized + Serialize { + fn into_writer(&self, writer: W) -> Result<(), ciborium::ser::Error> { + ciborium::into_writer(self, writer) + } + fn into_vec_u8(&self) -> Result, ciborium::ser::Error> { + let mut buf: Vec = Vec::new(); + self.into_writer(&mut buf)?; + Ok(buf) + } + fn from_reader(reader: R) -> Result> { + ciborium::from_reader(reader) + } +} + +pub trait Request: Into + From + AsyncTryInto +where T: Message { + type Response: Response; + async fn send_p2p(self) -> Result; + } + +pub trait Response: Into + From + AsyncTryFrom +where T: Message{ + type Request: Request; + async fn from_request_with_local(req: Self::Request) -> Result; + async fn from_request_with_p2p(req: Self::Request) -> Result { + todo!() + } +} + +pub trait FromDatabase { + async fn from_storage(); +} + + +pub trait P2pRequest: Into + From +where T: Message { + type P2pResponse: P2pResponse; + async fn send_p2p(&self) -> Result{ + todo!() + } +} +pub trait P2pResponse: Into + From + AsyncTryFrom<(Self::P2pRequest)> +where T: Message { + type P2pRequest: P2pRequest; + async fn try_from_p2p_request(source: Self::P2pRequest) -> Result; +} \ No newline at end of file diff --git a/lazy-supplements-core/src/message/node.rs b/lazy-supplements-core/src/message/node.rs new file mode 100644 index 0000000..c587259 --- /dev/null +++ b/lazy-supplements-core/src/message/node.rs @@ -0,0 +1,10 @@ +use serde::{Deserialize, Serialize}; + + +#[derive(Debug, Deserialize, Serialize)] +pub struct ListDeviceRequest; + +#[derive(Debug, Deserialize, Serialize)] +pub struct ListDeviceResponse { + node: Vec +} \ No newline at end of file diff --git a/lazy-supplements-core/src/p2p/error.rs b/lazy-supplements-core/src/p2p/error.rs new file mode 100644 index 0000000..6e2f187 --- /dev/null +++ b/lazy-supplements-core/src/p2p/error.rs @@ -0,0 +1,4 @@ +#[derive(thiserror::Error)] +pub enum P2pError { + +} \ No newline at end of file diff --git a/lazy-supplements-core/src/p2p/mod.rs b/lazy-supplements-core/src/p2p/mod.rs index e4931ae..f5bdecd 100644 --- a/lazy-supplements-core/src/p2p/mod.rs +++ b/lazy-supplements-core/src/p2p/mod.rs @@ -1,3 +1,4 @@ +pub mod error; use libp2p::{ identity::Keypair, mdns, ping, swarm}; use sea_orm::{ActiveModelTrait, ActiveValue::Set, ColumnTrait, EntityTrait, QueryFilter}; diff --git a/lazy-supplements-desktop/src/cli/config.rs b/lazy-supplements-desktop/src/cli/args/config.rs similarity index 50% rename from lazy-supplements-desktop/src/cli/config.rs rename to lazy-supplements-desktop/src/cli/args/config.rs index 4f2bc0e..8e1b580 100644 --- a/lazy-supplements-desktop/src/cli/config.rs +++ b/lazy-supplements-desktop/src/cli/args/config.rs @@ -1,23 +1,39 @@ use std::{net::IpAddr, path::PathBuf}; use clap::Args; -use lazy_supplements_core::config::{PartialConfig, PartialCoreConfig}; +use lazy_supplements_core::config::ConfigError; +use crate::config::{PartialP2pConfig, PartialStorageConfig}; +#[cfg(unix)] +use crate::config::PartialUnixConfig; + use serde::{Deserialize, Serialize}; -use crate::{config::{desktop::PartialDesktopConfig, CoreConfig}, error::Error, global::{DEFAULT_CONFIG_FILE_PATH, DEFAULT_PARTIAL_CORE_CONFIG,}}; +use crate::{ + config::PartialDesktopConfig, + error::Error, + global::{DEFAULT_CONFIG_FILE_PATH, DEFAULT_PARTIAL_CORE_CONFIG,} +}; #[derive(Args, Clone, Debug)] pub struct ConfigArgs { - #[arg(long)] - pub config: Option, + #[arg(short = "c", long = "config")] + pub file_path: Option, + #[arg(skip)] + pub file_content: Option>, #[command(flatten)] - pub core_config: PartialCoreConfig, - #[command(flatten)] - pub desktop_config: PartialDesktopConfig, + pub args: PartialDesktopConfig, } impl ConfigArgs { + pub fn get_file_path_or_default(&self) -> PathBuf { + self.file_path.unwrap_or(DEFAULT_CONFIG_FILE_PATH) + } + pub async fn get_or_read_file_content(&mut self) -> Result { + self.file_content.get_or_insert( + PartialDesktopConfig::read_from(self.get_config_path_or_default()).await + ).clone() + } pub fn get_config_path_or_default(&self) -> PathBuf { if let Some(x) = self.config.as_ref() { x.clone() diff --git a/lazy-supplements-desktop/src/cli/args/device.rs b/lazy-supplements-desktop/src/cli/args/device.rs new file mode 100644 index 0000000..c64c332 --- /dev/null +++ b/lazy-supplements-desktop/src/cli/args/device.rs @@ -0,0 +1,12 @@ +use clap::Args; +use libp2p::{Multiaddr, PeerId}; +use uuid::Uuid; + +#[derive(Args, Clone, Debug)] +#[group(multiple = false, required = true)] +pub struct DeviceArgs { + device_number: Option, + device_id: Option, + peer_id: Option, + multiaddr: Option, +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/args/mod.rs b/lazy-supplements-desktop/src/cli/args/mod.rs new file mode 100644 index 0000000..e4001bc --- /dev/null +++ b/lazy-supplements-desktop/src/cli/args/mod.rs @@ -0,0 +1,7 @@ +mod config; +mod device; +mod peer; + +pub use config::ConfigArgs; +pub use device::DeviceArgs; +pub use peer::PeerArgs; \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/args/peer.rs b/lazy-supplements-desktop/src/cli/args/peer.rs new file mode 100644 index 0000000..f78fd14 --- /dev/null +++ b/lazy-supplements-desktop/src/cli/args/peer.rs @@ -0,0 +1,10 @@ +use clap::Args; +use libp2p::{Multiaddr, PeerId}; + +#[derive(Args, Clone, Debug)] +#[group(multiple = false, required = true)] +pub struct PeerArgs { + cache_number: Option, + peer_id: Option, + multiaddr: Option, +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/device/add.rs b/lazy-supplements-desktop/src/cli/device/add.rs new file mode 100644 index 0000000..0314479 --- /dev/null +++ b/lazy-supplements-desktop/src/cli/device/add.rs @@ -0,0 +1,23 @@ +use clap::Args; + +use crate::cli::{ConfigArgs, RunnableCommand}; + +use crate::cli::PeerArgs; + +#[derive(Debug, Args)] +pub struct DeviceAddCommandArgs { + #[command(flatten)] + peer: PeerArgs, + #[arg(short, long)] + passcode: Option, + #[command(flatten)] + config: ConfigArgs +} + +impl RunnableCommand for DeviceAddCommandArgs { + async fn run(self) { + todo!() + } +} + + diff --git a/lazy-supplements-desktop/src/cli/device/list.rs b/lazy-supplements-desktop/src/cli/device/list.rs new file mode 100644 index 0000000..c802d5c --- /dev/null +++ b/lazy-supplements-desktop/src/cli/device/list.rs @@ -0,0 +1,15 @@ +use clap::Args; + +use crate::cli::{ConfigArgs, RunnableCommand}; + +#[derive(Debug, Args)] +pub struct DeviceListCommandArgs{ + #[command(flatten)] + config: ConfigArgs +} + +impl RunnableCommand for DeviceListCommandArgs { + async fn run(self) { + todo!() + } +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/device/mod.rs b/lazy-supplements-desktop/src/cli/device/mod.rs new file mode 100644 index 0000000..64c2747 --- /dev/null +++ b/lazy-supplements-desktop/src/cli/device/mod.rs @@ -0,0 +1,37 @@ +mod add; +mod list; +mod ping; +mod remove; +mod scan; + +pub use add::DeviceAddCommandArgs; +use libp2p::{Multiaddr, PeerId}; +pub use list::DeviceListCommandArgs; +pub use ping::DevicePingCommandArgs; +pub use remove::DeviceRemoveCommandArgs; +pub use scan::DeviceScanCommandArgs; + +use std::{net::IpAddr, ops::Mul, path::PathBuf, str::FromStr}; + +use clap::{Args, Parser, Subcommand}; + +use crate::{cli::ServerArgs, error::Error}; + +use super::ConfigArgs; + + +#[derive(Debug, Args)] +pub struct DeviceCommandArgs { + #[command(subcommand)] + pub command: DeviceSubcommand +} + +#[derive(Debug, Subcommand)] +pub enum DeviceSubcommand { + Add(DeviceAddCommandArgs), + List(DeviceListCommandArgs), + Ping(DevicePingCommandArgs), + Remove(DeviceRemoveCommandArgs), + Scan(DeviceScanCommandArgs), +} + diff --git a/lazy-supplements-desktop/src/cli/device/ping.rs b/lazy-supplements-desktop/src/cli/device/ping.rs new file mode 100644 index 0000000..af5ac67 --- /dev/null +++ b/lazy-supplements-desktop/src/cli/device/ping.rs @@ -0,0 +1,17 @@ +use clap::Args; + +use crate::cli::{ConfigArgs, PeerArgs, RunnableCommand}; + +#[derive(Debug, Args)] +pub struct DevicePingCommandArgs{ + #[command(flatten)] + peer: PeerArgs, + #[command(flatten)] + config: ConfigArgs +} + +impl RunnableCommand for DevicePingCommandArgs { + async fn run(self) { + todo!() + } +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/device/remove.rs b/lazy-supplements-desktop/src/cli/device/remove.rs new file mode 100644 index 0000000..d72db46 --- /dev/null +++ b/lazy-supplements-desktop/src/cli/device/remove.rs @@ -0,0 +1,17 @@ +use clap::Args; + +use crate::cli::{ConfigArgs, DeviceArgs, RunnableCommand}; + +#[derive(Debug, Args)] +pub struct DeviceRemoveCommandArgs{ + #[command(flatten)] + device: DeviceArgs, + #[command(flatten)] + config: ConfigArgs +} + +impl RunnableCommand for DeviceRemoveCommandArgs { + async fn run(self) { + todo!() + } +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/device/scan.rs b/lazy-supplements-desktop/src/cli/device/scan.rs new file mode 100644 index 0000000..1277c6e --- /dev/null +++ b/lazy-supplements-desktop/src/cli/device/scan.rs @@ -0,0 +1,15 @@ +use clap::Args; + +use crate::cli::{ConfigArgs, RunnableCommand}; + +#[derive(Debug, Args)] +pub struct DeviceScanCommandArgs{ + #[command(flatten)] + config: ConfigArgs +} + +impl RunnableCommand for DeviceScanCommandArgs { + async fn run(self) { + todo!() + } +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/logs.rs b/lazy-supplements-desktop/src/cli/logs.rs new file mode 100644 index 0000000..d4d83ea --- /dev/null +++ b/lazy-supplements-desktop/src/cli/logs.rs @@ -0,0 +1,4 @@ +#[derive(Args, Debug)] +pub struct LogsCommandArgs { + +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/mod.rs b/lazy-supplements-desktop/src/cli/mod.rs index 738fe0d..9f36a6b 100644 --- a/lazy-supplements-desktop/src/cli/mod.rs +++ b/lazy-supplements-desktop/src/cli/mod.rs @@ -1,9 +1,13 @@ use std::path::PathBuf; -mod config; -mod node; +mod args; +mod device; mod server; -pub use config::ConfigArgs; -pub use node::{ NodeArgs, NodeCommand, PeerArgs , ConsoleNodeArgs}; -pub use server::ServerArgs; \ No newline at end of file +pub use args::*; +pub use device::*; +pub use server::*; + +pub trait RunnableCommand { + async fn run(self); +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/cli/node.rs b/lazy-supplements-desktop/src/cli/node.rs deleted file mode 100644 index be048b2..0000000 --- a/lazy-supplements-desktop/src/cli/node.rs +++ /dev/null @@ -1,81 +0,0 @@ -use std::{net::IpAddr, ops::Mul, path::PathBuf, str::FromStr}; - -use clap::{Args, Parser, Subcommand}; -use libp2p::{ - multiaddr::Protocol, noise, ping, swarm::SwarmEvent, tcp, yamux, Multiaddr, PeerId -}; - -use crate::{cli::ServerArgs, error::Error}; - -use super::ConfigArgs; - -#[derive(Debug, Args)] -pub struct NodeArgs { - #[command(subcommand)] - pub command: NodeCommand -} - -#[derive(Debug, Parser)] -pub struct ConsoleNodeArgs { - #[command(flatten)] - pub args: NodeArgs, -} - -impl NodeArgs { - pub async fn run(self) -> Result<(), Error> { - println!("{self:?}"); - Ok(()) - } -} - -#[derive(Args, Debug)] -pub struct PeerArgs { - #[arg(value_parser = clap::value_parser!(PeerArg))] - pub peer: PeerArg, -} -#[derive(Clone, Debug)] -pub enum PeerArg { - Addr(Multiaddr), - Id(PeerId), - Number(u32), -} - -impl FromStr for PeerArg { - type Err = String; - fn from_str(s: &str) -> Result { - if let Ok(x) = s.parse::() { - Ok(Self::Addr(x)) - } else if let Ok(x) = s.parse::() { - Ok(Self::Id(x)) - } else if let Ok(x) = s.parse::() { - Ok(Self::Number(x)) - } else { - Err(format!("Invalid value: {s}").to_string()) - } - } -} - - -#[derive(Args, Debug)] -pub struct NodeJoinArgs { - #[command(flatten)] - pub peer: PeerArgs, - pub pass: Option, -} - -#[derive(Debug, Subcommand)] -pub enum NodeCommand { - Add(PeerArgs), - Ping(PeerArgs), - Join(PeerArgs), - List, - Delete(PeerArgs), -} - - -impl PeerArgs { - pub async fn run(self) -> Result<(), Error> { - println!("{self:?}"); - todo!() - } -} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/config/mod.rs b/lazy-supplements-desktop/src/config/mod.rs index c64446b..4db9f5f 100644 --- a/lazy-supplements-desktop/src/config/mod.rs +++ b/lazy-supplements-desktop/src/config/mod.rs @@ -3,13 +3,30 @@ pub mod unix; #[cfg(windows)] pub mod windows; -pub mod desktop; + pub use lazy_supplements_core::config::*; - - +use serde::{Deserialize, Serialize}; #[cfg(unix)] pub use unix::*; #[cfg(windows)] -pub use windows::*; \ No newline at end of file +pub use windows::*; + +#[derive(Debug, Deserialize, Serialize)] +pub struct PartialDesktopConfig { + p2p: PartialP2pConfig, + storage: PartialStorageConfig, + #[cfg(unix)] + unix: PartialUnixConfig, +} + +impl PartialConfigRoot for PartialDesktopConfig { + fn new() -> Self { + Self { + p2p : PartialP2pConfig::empty().with_new_secret(), + storage: PartialStorageConfig::empty(), + unix: PartialUnixConfig::empty(), + } + } +} \ No newline at end of file diff --git a/lazy-supplements-desktop/src/config/unix.rs b/lazy-supplements-desktop/src/config/unix.rs index 35dcafe..c02d72f 100644 --- a/lazy-supplements-desktop/src/config/unix.rs +++ b/lazy-supplements-desktop/src/config/unix.rs @@ -40,6 +40,9 @@ impl PartialConfig for PartialUnixConfig { fn default() -> Self { todo!() } + fn is_empty(&self) -> bool { + self.socket_path.is_none() + } fn merge(&mut self, other: Self) { if let Some(x) = other.socket_path { self.socket_path = Some(x); diff --git a/lazy-supplements-desktop/src/ipc/message/mod.rs b/lazy-supplements-desktop/src/ipc/message/mod.rs index 56ee0d9..e50c061 100644 --- a/lazy-supplements-desktop/src/ipc/message/mod.rs +++ b/lazy-supplements-desktop/src/ipc/message/mod.rs @@ -1,4 +1,17 @@ mod response; mod request; pub use response::*; -pub use request::*; \ No newline at end of file +pub use request::*; + +pub trait IpcRequest { + type IpcResponse: IpcResponse; + async fn try_into_p2p_response(&self) -> Result { + + } +} + +pub trait IpcResponse { + type IpcRequest: IpcRequest; + async fn try_from_ipc_request(&self) -> Result; + +} \ No newline at end of file