changeset 13:2d2296e5bcf4 draft

Start implementing configuration types
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 03 Dec 2016 11:18:58 +0100
parents d680d7f1bec8
children e101908dc688
files src/config.rs
diffstat 1 files changed, 58 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/config.rs	Sat Dec 03 11:18:41 2016 +0100
+++ b/src/config.rs	Sat Dec 03 11:18:58 2016 +0100
@@ -1,15 +1,65 @@
+//! See prototype.toml for a full example config file.
+//!
 
-#[derive(Clone)]
-pub struct Config {
+use std::net::SocketAddr;
+
+#[derive(Clone,Default)]
+pub struct General {
     pub bind_path: String,
     pub max_msg_len: usize,
 }
 
-impl Default for Config {
-    fn default() -> Config {
-        Config {
-            bind_path: "/dev/log".to_string(),
-            max_msg_len: 2048,
-        }
+#[derive(Clone)]
+pub struct Remote {
+    addr: SocketAddr
+}
+
+#[derive(Clone)]
+pub enum CompressType {
+    NoCompression,
+    // NOTE: use flate2 for compression.
+    Gzip
+}
+
+impl Default for CompressType {
+    fn default() -> CompressType {
+        CompressType::NoCompression
     }
 }
+
+#[derive(Clone,Default)]
+pub struct File {
+    name: String,
+    location: String,
+    /// bytes
+    max_size: usize,
+    /// seconds
+    max_age: u64,
+    history: i32,
+    compress: CompressType,
+}
+
+#[derive(Clone)]
+pub enum Pattern {
+    /// '*'
+    Wildcard,
+}
+
+impl Default for Pattern {
+    fn default() -> Pattern {
+        Pattern::Wildcard
+    }
+}
+
+#[derive(Clone,Default)]
+pub struct Rule {
+    level_pattern: Pattern,
+    // referes to File.name
+    dest: String,
+}
+
+#[derive(Clone,Default)]
+pub struct Config {
+    pub general: General,
+}
+