use std::path::{Path, PathBuf};
pub struct FileHandler {
- pub strategies: Vec<Box<dyn FileHandlerStrategy>>,
+ pub strategies: Vec<Box<dyn Strategy>>,
pub layout: Option<String>,
}
impl FileHandler {
pub fn identify(&self, path: &Path) -> FileType {
- for strategy in self.strategies.iter() {
+ for strategy in &self.strategies {
if strategy.is(path) {
return strategy.identify();
}
gemini_destination: &Path,
files: &[File],
) {
- files.iter().for_each(|file| {
+ for file in files {
self.handle(source, html_destination, gemini_destination, file);
- });
+ }
}
pub fn handle(
}
}
-pub trait FileHandlerStrategy {
+pub trait Strategy {
fn is(&self, path: &Path) -> bool;
fn identify(&self) -> FileType;
fn can_handle(&self, file_type: &FileType) -> bool;
file_type: FileType,
}
- impl FileHandlerStrategy for MockStrategy {
+ impl Strategy for MockStrategy {
fn is(&self, _path: &Path) -> bool {
self.is_match
}