diff options
author | Akshay <[email protected]> | 2020-04-12 07:41:02 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-04-12 07:41:02 +0100 |
commit | f1f564dfcd328a1b36e6fefb37e023afebc9d68f (patch) | |
tree | eed4d74e5334ddf76c9d604f67d3ee9c7b8214b6 /fondant_derive | |
parent | 79f1ea075d0d3ad3514da7120faa1c3c5fd17bfc (diff) |
all loading paths at runtime
Diffstat (limited to 'fondant_derive')
-rw-r--r-- | fondant_derive/src/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fondant_derive/src/lib.rs b/fondant_derive/src/lib.rs index a06df15..2f852dc 100644 --- a/fondant_derive/src/lib.rs +++ b/fondant_derive/src/lib.rs | |||
@@ -127,8 +127,8 @@ fn gen_impl(ast: &DeriveInput, cfg_path: ConfigPath) -> TokenStream { | |||
127 | Self::load_file(&config_file) | 127 | Self::load_file(&config_file) |
128 | } | 128 | } |
129 | 129 | ||
130 | fn load_file(conf_file: &PathBuf) -> Result<#struct_ident, FondantError> { | 130 | fn load_file<P: AsRef<Path>>(conf_file: P) -> Result<#struct_ident, FondantError> { |
131 | #load_paths | 131 | #load_paths |
132 | match File::open(&conf_file) { // Note: conf_file is different than config_file from #load_paths | 132 | match File::open(&conf_file) { // Note: conf_file is different than config_file from #load_paths |
133 | Ok(mut cfg) => { | 133 | Ok(mut cfg) => { |
134 | let mut cfg_data = String::new(); | 134 | let mut cfg_data = String::new(); |
@@ -149,13 +149,14 @@ fn gen_impl(ast: &DeriveInput, cfg_path: ConfigPath) -> TokenStream { | |||
149 | Err(e) => return Err(FondantError::LoadError), | 149 | Err(e) => return Err(FondantError::LoadError), |
150 | }; | 150 | }; |
151 | } | 151 | } |
152 | |||
152 | fn store(&self) -> Result<(), FondantError> { | 153 | fn store(&self) -> Result<(), FondantError> { |
153 | #load_paths | 154 | #load_paths |
154 | &self.store_file(&config_file)?; | 155 | &self.store_file(&config_file)?; |
155 | Ok(()) | 156 | Ok(()) |
156 | } | 157 | } |
157 | 158 | ||
158 | fn store_file(&self, conf_file: &PathBuf) -> Result<(), FondantError> { | 159 | fn store_file<P: AsRef<Path>>(&self, conf_file: P) -> Result<(), FondantError> { |
159 | #load_paths | 160 | #load_paths |
160 | let mut f = OpenOptions::new() | 161 | let mut f = OpenOptions::new() |
161 | .write(true) | 162 | .write(true) |