From 52b377eaa14b0457dc911d3db08ba7289e099507 Mon Sep 17 00:00:00 2001 From: Robert Ignat Date: Tue, 6 Jun 2017 22:36:20 +0200 Subject: [PATCH] Make configuration traits methods non-static --- imag-link/src/main.rs | 6 +++--- libimagrt/src/configuration.rs | 6 +++--- libimagrt/src/runtime.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index 87c52bb2..0f6ead7a 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -388,7 +388,7 @@ version = \"0.3.0\"\ } impl<'a> GetConfiguration for MockLinkApp<'a> { - fn get_configuration(_: &PathBuf) -> ConfigResult { + fn get_configuration(&self, _: &PathBuf) -> ConfigResult { ::toml::de::from_slice(TOML_CONFIG_FILE) .map_err(|_| { ConfigErrorKind::TOMLParserError.into() @@ -398,11 +398,11 @@ version = \"0.3.0\"\ } impl<'a> InternalConfiguration for MockLinkApp<'a> { - fn enable_hooks() -> bool { + fn enable_hooks(&self) -> bool { false } - fn enable_logging() -> bool { + fn enable_logging(&self) -> bool { false } } diff --git a/libimagrt/src/configuration.rs b/libimagrt/src/configuration.rs index 1b74532a..d1aa896c 100644 --- a/libimagrt/src/configuration.rs +++ b/libimagrt/src/configuration.rs @@ -216,7 +216,7 @@ pub trait GetConfiguration { /// /// Default implementation tests several variants for the config file path and uses the first /// one which works. - fn get_configuration(rtp: &PathBuf) -> Result { + fn get_configuration(&self, rtp: &PathBuf) -> Result { use std::env; use std::fs::File; use std::io::Read; @@ -280,11 +280,11 @@ pub trait GetConfiguration { impl<'a> GetConfiguration for App<'a, 'a> {} pub trait InternalConfiguration { - fn enable_hooks() -> bool { + fn enable_hooks(&self) -> bool { true } - fn enable_logging() -> bool { + fn enable_logging(&self) -> bool { true } } diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index e5d88c62..57f4f170 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -75,7 +75,7 @@ impl<'a> Runtime<'a> { let is_verbose = matches.is_present("verbosity"); let colored = !matches.is_present("no-color-output"); - if C::enable_logging() { + if cli_app.enable_logging() { Runtime::init_logger(is_debugging, is_verbose, colored); } @@ -112,7 +112,7 @@ impl<'a> Runtime<'a> { debug!("Store path = {:?}", storepath); debug!("Config path = {:?}", configpath); - let cfg = match C::get_configuration(&configpath) { + let cfg = match cli_app.get_configuration(&configpath) { Err(e) => if e.err_type() != ConfigErrorKind::NoConfigFileFound { return Err(RuntimeErrorKind::Instantiate.into_error_with_cause(Box::new(e))); } else {