Files
lan-mouse/src/config.rs
Ferdinand Schober 4c66b37a2f enable conditional compilation for all backends
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
2023-02-17 13:06:13 +01:00

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)?)
}
}