2025-06-18 08:36:01 +09:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use clap::Args;
|
2025-07-05 10:30:55 +09:00
|
|
|
use lazy_supplements_core::{config::PartialConfig, utils::{emptiable::Emptiable, mergeable::Mergeable}};
|
2025-06-18 08:36:01 +09:00
|
|
|
use libp2p::mdns::Config;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
use crate::config::error::ConfigError;
|
|
|
|
|
|
|
|
|
|
|
|
pub struct UnixConfig {
|
|
|
|
pub socket_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<PartialUnixConfig> for UnixConfig {
|
|
|
|
type Error = ConfigError;
|
|
|
|
fn try_from(config: PartialUnixConfig) -> Result<Self, Self::Error> {
|
|
|
|
Ok(Self{
|
|
|
|
socket_path: config.socket_path.ok_or(ConfigError::MissingConfig("socket_path".to_string()))?
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-07-05 10:30:55 +09:00
|
|
|
#[derive(Args, Clone, Debug, Deserialize, Emptiable, Mergeable, Serialize)]
|
2025-06-18 08:36:01 +09:00
|
|
|
pub struct PartialUnixConfig {
|
|
|
|
pub socket_path: Option<PathBuf>,
|
|
|
|
}
|
|
|
|
|
2025-07-05 10:30:55 +09:00
|
|
|
impl Default for PartialUnixConfig {
|
|
|
|
fn default() -> Self {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-06-18 08:36:01 +09:00
|
|
|
impl From<UnixConfig> for PartialUnixConfig {
|
|
|
|
fn from(source: UnixConfig) -> Self {
|
|
|
|
Self {
|
|
|
|
socket_path: Some(source.socket_path)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-07-05 10:30:55 +09:00
|
|
|
|