mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-28 15:40:54 +03:00
Keyboard support + data requests via tcp server
This commit is contained in:
32
src/config.rs
Normal file
32
src/config.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use toml;
|
||||
use std::net::IpAddr;
|
||||
use std::{fs, error::Error};
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize,Deserialize,Debug)]
|
||||
pub struct Config {
|
||||
pub client: Clients,
|
||||
pub port: Option<u16>,
|
||||
}
|
||||
|
||||
#[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)]
|
||||
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).unwrap())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user