mdBook/src/book/bookitem.rs

42 lines
699 B
Rust
Raw Normal View History

2015-07-17 01:26:16 +08:00
use std::path::PathBuf;
pub struct BookItem {
pub name: String,
pub path: PathBuf,
pub sub_items: Vec<BookItem>,
spacer: bool,
2015-07-17 01:26:16 +08:00
}
pub enum ItemType {
Pre,
Chapter,
Post
}
2015-07-17 01:26:16 +08:00
impl BookItem {
pub fn new(name: String, path: PathBuf) -> Self {
2015-07-17 01:26:16 +08:00
BookItem {
name: name,
path: path,
sub_items: vec![],
spacer: false,
}
}
pub fn spacer() -> Self {
BookItem {
name: String::from("SPACER"),
path: PathBuf::new(),
sub_items: vec![],
spacer: true,
2015-07-17 01:26:16 +08:00
}
}
fn push(&mut self, item: BookItem) {
self.sub_items.push(item);
}
2015-07-17 01:26:16 +08:00
}