[−][src]Enum gen_epub_book::ops::IncludeDirectory
Representation of an
-I
nclude directory.
Textually,
unnamed -I
nclude directories take the form of "path"
, and
named -I
nclude directories take the form of "name=path"
.
Variants
Unnamed
An unnamed include directory, acting transparently
Fields of Unnamed
Named
A named include directory, saved with prefixes.
Fields of Named
Methods
impl IncludeDirectory
[src]
pub fn directory_name(&self) -> &str
[src]
Get the name of the include directory
(Also known as self.dir.0
, but it's a convenience function, because :enums:.)
Examples
assert_eq!( IncludeDirectory::Unnamed { dir: ("cur-dir".to_string(), PathBuf::from(".")), }.directory_name(), "cur-dir"); assert_eq!( IncludeDirectory::Named { name: "dot".to_string(), dir: ("named-cur-dir".to_string(), PathBuf::from(".")), }.directory_name(), "named-cur-dir");
pub fn packed_name<P: AsRef<Path>>(&self, f: P) -> PathBuf
[src]
Get packed filename for file specified by path.
Basically optionally prefixes util::book_filename()
.
Path separator, if any, is always '/'
.
Examples
let fname = Path::new("content/ch01.html"); assert_eq!( IncludeDirectory::Unnamed { dir: ("cur-dir".to_string(), PathBuf::from(".")), }.packed_name(&fname), book_filename(&fname)); assert_eq!( IncludeDirectory::Named { name: "dot".to_string(), dir: ("named-cur-dir".to_string(), PathBuf::from(".")), }.packed_name(&fname).display().to_string(), format!("dot/{}", book_filename(&fname).display()));
pub fn packed_id(&self, f: &Path) -> String
[src]
Get the (X)HTML ID from a path.
Basically optionally prefixes util::xhtml_path_id()
.
Examples
let fname = Path::new("content/ch01.html"); assert_eq!( IncludeDirectory::Unnamed { dir: ("cur-dir".to_string(), PathBuf::from(".")), }.packed_id(&fname), xhtml_path_id(&fname)); assert_eq!( IncludeDirectory::Named { name: "dot".to_string(), dir: ("named-cur-dir".to_string(), PathBuf::from(".")), }.packed_id(&fname), format!("dot--{}", xhtml_path_id(&fname)));
pub fn resolve<P: AsRef<Path>>(&self, relpath: P) -> Option<PathBuf>
[src]
Resolve the path of the specified file in this include directory, or None
if nonexistant or isn't a file.
Examples
let default_dir = special_book.join("gep").join("special"); let previews_dir = special_book.join("previews").join("generated").join("out"); let rendered_dir = special_book.join("rendered").join("output"); let default = IncludeDirectory::Unnamed { dir: ("".to_string(), default_dir.clone()), }; let previews = IncludeDirectory::Named { name: "previews".to_string(), dir: ("../../previews/generated/out".to_string(), previews_dir.clone()), }; let rendered = IncludeDirectory::Unnamed { dir: ("../../rendered/output".to_string(), rendered_dir.clone()), }; assert_eq!(default.resolve(Path::new("intro.html")), Some(default_dir.join("intro.html"))); assert_eq!(previews.resolve(Path::new("main.html")), Some(previews_dir.join("main.html"))); assert_eq!(rendered.resolve(Path::new("ending.html")), Some(rendered_dir.join("ending.html"))); assert_eq!(default.resolve(Path::new("cover.png")), None); assert_eq!(default.resolve(Path::new("../special")), None);
Trait Implementations
impl PartialEq<IncludeDirectory> for IncludeDirectory
[src]
fn eq(&self, other: &IncludeDirectory) -> bool
[src]
fn ne(&self, other: &IncludeDirectory) -> bool
[src]
impl Ord for IncludeDirectory
[src]
fn cmp(&self, other: &IncludeDirectory) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Clone for IncludeDirectory
[src]
fn clone(&self) -> IncludeDirectory
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for IncludeDirectory
[src]
impl PartialOrd<IncludeDirectory> for IncludeDirectory
[src]
fn partial_cmp(&self, other: &IncludeDirectory) -> Option<Ordering>
[src]
fn lt(&self, other: &IncludeDirectory) -> bool
[src]
fn le(&self, other: &IncludeDirectory) -> bool
[src]
fn gt(&self, other: &IncludeDirectory) -> bool
[src]
fn ge(&self, other: &IncludeDirectory) -> bool
[src]
impl Debug for IncludeDirectory
[src]
impl Display for IncludeDirectory
[src]
impl Hash for IncludeDirectory
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromStr for IncludeDirectory
[src]
Auto Trait Implementations
impl Send for IncludeDirectory
impl Sync for IncludeDirectory
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,