mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-11 07:10:54 +03:00
To reduce binary size one can now enable only specific backends, e.g. wayland or x11 via cargo features Additionally adds stubs for libei and xdg-desktop-portal backends
34 lines
786 B
Rust
34 lines
786 B
Rust
use serde_derive::{Deserialize, Serialize};
|
|
use std::net::IpAddr;
|
|
use std::{error::Error, fs};
|
|
use toml;
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct Config {
|
|
pub client: Clients,
|
|
pub port: Option<u16>,
|
|
pub backend: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct Clients {
|
|
pub left: Option<Client>,
|
|
pub right: Option<Client>,
|
|
pub top: Option<Client>,
|
|
pub bottom: Option<Client>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
|
pub struct Client {
|
|
pub host_name: Option<String>,
|
|
pub ip: Option<IpAddr>,
|
|
pub port: Option<u16>,
|
|
}
|
|
|
|
impl Config {
|
|
pub fn new(path: &str) -> Result<Config, Box<dyn Error>> {
|
|
let config = fs::read_to_string(path)?;
|
|
Ok(toml::from_str::<_>(&config)?)
|
|
}
|
|
}
|