seperated crate into lib and binary

This commit is contained in:
Janis 2021-11-30 15:47:42 +01:00
parent f26ca7948b
commit 81a49e8290
3 changed files with 30 additions and 27 deletions

View file

@ -4,6 +4,10 @@ version = "0.2.0"
authors = ["noonebtw <noonebtw@gmail.com>"]
edition = "2018"
[[bin]]
name = "nowm"
path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

24
src/lib.rs Normal file
View file

@ -0,0 +1,24 @@
pub mod backends;
pub mod clients;
pub mod state;
pub mod util;
pub mod error {
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("placeholder error for Result<T> as Option<T>")]
NonError,
#[error("Unknown Event")]
UnknownEvent,
#[error("Unhandled VirtualKeyCode")]
UnhandledVirtualKeyCode,
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
FmtError(#[from] std::fmt::Error),
#[error(transparent)]
XlibError(#[from] crate::backends::xlib::XlibError),
}
}

View file

@ -7,32 +7,8 @@ use log4rs::{
encode::pattern::PatternEncoder,
Config,
};
use state::WMConfig;
mod backends;
mod clients;
mod state;
mod util;
pub mod error {
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("placeholder error for Result<T> as Option<T>")]
NonError,
#[error("Unknown Event")]
UnknownEvent,
#[error("Unhandled VirtualKeyCode")]
UnhandledVirtualKeyCode,
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
FmtError(#[from] std::fmt::Error),
#[error(transparent)]
XlibError(#[from] crate::backends::xlib::XlibError),
}
}
use wm::state::WMConfig;
fn init_logger() {
let encoder = Box::new(PatternEncoder::new(
@ -83,7 +59,7 @@ fn main() {
WMConfig::default()
});
state::WindowManager::<backends::xlib::XLib>::new(config).run();
wm::state::WindowManager::<wm::backends::xlib::XLib>::new(config).run();
}
fn log_prologue() {
@ -102,7 +78,6 @@ fn log_prologue() {
#[test]
fn test_logger() {
init_logger();
// asdf
log_prologue();
}