From 08b42805ff875ee2b9f6b8490c4015547fe26b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sat, 30 Dec 2017 21:25:17 +0100 Subject: [PATCH] Move application constants to module --- src/app.rs | 18 ++++++++++++++++++ src/main.rs | 28 +++++++--------------------- 2 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 src/app.rs diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..520eb7a --- /dev/null +++ b/src/app.rs @@ -0,0 +1,18 @@ +// Application properties +pub const APP_NAME: &'static str = "pixelpwnr"; +pub const APP_VERSION: &'static str = "0.1"; +pub const APP_AUTHOR: &'static str = "Tim Visee "; +pub const APP_ABOUT: &'static str = "A quick pixelflut client, that pwns pixelflut panels."; + +// The default thread count +pub const DEFAULT_THREAD_COUNT: usize = 4; + +// The default image width and height +pub const DEFAULT_IMAGE_WIDTH: u32 = 1920; +pub const DEFAULT_IMAGE_HEIGHT: u32 = 1080; + +// The default frames per second rate +pub const DEFAULT_IMAGE_FPS: u32 = 1; + +// The amount of milliseconds to wait for an image, when a painter has no image. +pub const PAINTER_IMAGE_WAIT_DELAY_MILLIS: u64 = 100; diff --git a/src/main.rs b/src/main.rs index 1665645..99cbe3c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,8 @@ extern crate bufstream; extern crate clap; extern crate image; +mod app; + use std::io::Error; use std::io::prelude::*; use std::net::TcpStream; @@ -16,23 +18,7 @@ use bufstream::BufStream; use clap::{Arg, ArgMatches, App}; use image::{DynamicImage, FilterType, Pixel}; - - -// The default thread count -const DEFAULT_THREAD_COUNT: usize = 4; - -// The default image width and height -const DEFAULT_IMAGE_WIDTH: u32 = 1920; -const DEFAULT_IMAGE_HEIGHT: u32 = 1080; - -// The default frames per second rate -const DEFAULT_IMAGE_FPS: u32 = 1; - -// The amount of milliseconds to wait for an image, when a painter has no image. -const PAINTER_IMAGE_WAIT_DELAY_MILLIS: u64 = 100; - -// The default size of the command output read buffer -// const CMD_READ_BUFFER_SIZE: usize = 16; +use app::*; @@ -104,10 +90,10 @@ fn main() { /// Parse CLI arguments, return the matches. fn parse_args<'a>() -> ArgMatches<'a> { // Handle/parse arguments - App::new("pixelpwnr") - .version("0.1") - .author("Tim Visee ") - .about("Pwns pixelflut") + App::new(APP_NAME) + .version(APP_VERSION) + .author(APP_AUTHOR) + .about(APP_ABOUT) .arg(Arg::with_name("HOST") .help("The host to pwn \"host:port\"") .required(true)