pub enum Import {
Simple(String),
Detailed(DetailedImport),
}
Expand description
A file to import, with optionally a condition
Variants§
Simple(String)
Detailed(DetailedImport)
Implementations§
source§impl Import
impl Import
sourcepub fn applies(&self) -> bool
pub fn applies(&self) -> bool
Examples found in repository?
src/conf/conf.rs (line 198)
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
pub fn read_file(
&mut self,
path: PathBuf,
) -> Result<(), ProgramError> {
debug!("reading conf file: {:?}", &path);
let mut conf: Conf = SerdeFormat::read_file(&path)?;
overwrite!(self, default_flags, conf);
overwrite!(self, date_time_format, conf);
overwrite!(self, icon_theme, conf);
overwrite!(self, syntax_theme, conf);
overwrite!(self, disable_mouse_capture, conf);
overwrite!(self, capture_mouse, conf);
overwrite!(self, true_colors, conf);
overwrite!(self, show_selection_mark, conf);
overwrite!(self, cols_order, conf);
overwrite!(self, skin, conf);
overwrite!(self, search_modes, conf);
overwrite!(self, max_panels_count, conf);
overwrite!(self, modal, conf);
overwrite!(self, quit_on_last_cancel, conf);
overwrite!(self, file_sum_threads_count, conf);
overwrite!(self, max_staged_count, conf);
overwrite!(self, show_matching_characters_on_path_searches, conf);
overwrite!(self, content_search_max_file_size, conf);
self.verbs.append(&mut conf.verbs);
// the following maps are "additive": we can add entries from several
// config files and they still make sense
overwrite_map!(self, special_paths, conf);
overwrite_map!(self, ext_colors, conf);
self.files.push(path);
// read the imports
for import in &conf.imports {
let file = import.file();
if !import.applies() {
debug!("skipping not applying conf file : {:?}", file);
continue;
}
let import_path = self.solve_conf_path(file)
.ok_or_else(|| ConfError::ImportNotFound { path: file.to_string() })?;
if self.files.contains(&import_path) {
debug!("skipping import already read: {:?}", import_path);
continue;
}
self.read_file(import_path)?;
}
Ok(())
}
sourcepub fn luma(&self) -> Option<&LumaCondition>
pub fn luma(&self) -> Option<&LumaCondition>
sourcepub fn file(&self) -> &str
pub fn file(&self) -> &str
Examples found in repository?
src/conf/conf.rs (line 197)
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
pub fn read_file(
&mut self,
path: PathBuf,
) -> Result<(), ProgramError> {
debug!("reading conf file: {:?}", &path);
let mut conf: Conf = SerdeFormat::read_file(&path)?;
overwrite!(self, default_flags, conf);
overwrite!(self, date_time_format, conf);
overwrite!(self, icon_theme, conf);
overwrite!(self, syntax_theme, conf);
overwrite!(self, disable_mouse_capture, conf);
overwrite!(self, capture_mouse, conf);
overwrite!(self, true_colors, conf);
overwrite!(self, show_selection_mark, conf);
overwrite!(self, cols_order, conf);
overwrite!(self, skin, conf);
overwrite!(self, search_modes, conf);
overwrite!(self, max_panels_count, conf);
overwrite!(self, modal, conf);
overwrite!(self, quit_on_last_cancel, conf);
overwrite!(self, file_sum_threads_count, conf);
overwrite!(self, max_staged_count, conf);
overwrite!(self, show_matching_characters_on_path_searches, conf);
overwrite!(self, content_search_max_file_size, conf);
self.verbs.append(&mut conf.verbs);
// the following maps are "additive": we can add entries from several
// config files and they still make sense
overwrite_map!(self, special_paths, conf);
overwrite_map!(self, ext_colors, conf);
self.files.push(path);
// read the imports
for import in &conf.imports {
let file = import.file();
if !import.applies() {
debug!("skipping not applying conf file : {:?}", file);
continue;
}
let import_path = self.solve_conf_path(file)
.ok_or_else(|| ConfError::ImportNotFound { path: file.to_string() })?;
if self.files.contains(&import_path) {
debug!("skipping import already read: {:?}", import_path);
continue;
}
self.read_file(import_path)?;
}
Ok(())
}
Trait Implementations§
source§impl<'de> Deserialize<'de> for Import
impl<'de> Deserialize<'de> for Import
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more