[−][src]Function gen_epub_book::ops::find_file
pub fn find_file<P: AsRef<Path>>(
file: P,
include_order: &[IncludeDirectory]
) -> Option<&IncludeDirectory>
Find an appropriate IncludeDirectory
for the specified file, or None
otherwise
Examples
Given:
special_book
├── rendered
│ └── output
│ ├── intro.html
│ ├── main.html
│ └── ending.html
├── previews
│ └── generated
│ └── out
│ ├── intro.html
│ └── main.html
└── gep
└── special
├── intro.html
└── book.epupp
The following holds:
let default = IncludeDirectory::Unnamed { dir: ("".to_string(), special_book.join("gep").join("special")), }; let previews = IncludeDirectory::Named { name: "previews".to_string(), dir: ("../../previews/generated/out".to_string(), special_book.join("previews").join("generated").join("out")), }; let rendered = IncludeDirectory::Unnamed { dir: ("../../rendered/output".to_string(), special_book.join("rendered").join("output")), }; let include_order = [default.clone(), previews.clone(), rendered.clone()]; assert_eq!(find_file(&Path::new("intro.html"), &include_order), Some(&default)); assert_eq!(find_file(&Path::new("main.html"), &include_order), Some(&previews)); assert_eq!(find_file(&Path::new("ending.html"), &include_order), Some(&rendered)); assert_eq!(find_file(&Path::new("cover.png"), &include_order), None);