diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-01-02 16:10:12 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-01-02 16:10:25 +0100 |
commit | f53951a43c887963605b52b30237b8aa61aa7c09 (patch) | |
tree | be0fa55133b015c5daf7e2d1b2ea9d50fbeef44e /src | |
parent | d7df41df65d3928391ecb658da9d0c63a0966250 (diff) |
Replace implementation of getters with getset::Gettersmy-master
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 43 | ||||
-rw-r--r-- | src/main.rs | 1 |
2 files changed, 16 insertions, 28 deletions
diff --git a/src/config.rs b/src/config.rs index 9441973..c2aa960 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,6 +6,7 @@ extern crate toml; use std::path::PathBuf; use regex::Regex; use error::*; +use getset::Getters; //------------------------------------// // structs for deserialization // @@ -56,11 +57,21 @@ impl ConfigDeser { /// The deserialized Item would nearly always require some operation on its /// contents to use it, so we do those operations beforehand and only access /// the useful data from main(). +#[derive(Getters)] pub struct LogItem { + #[getset(get = "pub")] file : String, + + #[getset(get = "pub")] regex : Regex, + + #[getset(get = "pub")] alias : String, + + #[getset(get = "pub")] capture_names : Vec<String>, + + #[getset(get = "pub")] aliases : Vec<String>, } @@ -105,31 +116,15 @@ impl LogItem { } ) } - - pub fn file(&self) -> &String { - &self.file - } - - pub fn regex(&self) -> &Regex { - &self.regex - } - - pub fn alias(&self) -> &String { - &self.alias - } - - pub fn capture_names(&self) -> &Vec<String> { - &self.capture_names - } - - pub fn aliases(&self) -> &Vec<String> { - &self.aliases - } } /// Contains more immediately usable data +#[derive(Getters)] pub struct Config { + #[getset(get = "pub")] items : Vec<LogItem>, + + #[getset(get = "pub")] all_aliases : Vec<String>, } @@ -155,13 +150,5 @@ impl Config { Ok(Config { items: l_items, all_aliases : all_als }) } - - pub fn items(&self) -> &Vec<LogItem> { - &self.items - } - - pub fn all_aliases(&self) -> &Vec<String> { - &self.all_aliases - } } diff --git a/src/main.rs b/src/main.rs index 6b3c2d6..3eb81f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ extern crate serde; extern crate serde_derive; extern crate serde_json; extern crate simplelog; +extern crate getset; use std::collections::HashMap; use std::fs::File; |