2015-07-17 01:26:16 +08:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
pub struct BookItem {
|
2015-07-18 06:04:20 +08:00
|
|
|
pub name: String,
|
|
|
|
pub path: PathBuf,
|
|
|
|
pub sub_items: Vec<BookItem>,
|
|
|
|
spacer: bool,
|
2015-07-17 01:26:16 +08:00
|
|
|
}
|
|
|
|
|
2015-07-18 06:04:20 +08:00
|
|
|
pub enum ItemType {
|
|
|
|
Pre,
|
|
|
|
Chapter,
|
|
|
|
Post
|
|
|
|
}
|
2015-07-17 01:26:16 +08:00
|
|
|
|
|
|
|
impl BookItem {
|
|
|
|
|
2015-07-18 06:04:20 +08:00
|
|
|
pub fn new(name: String, path: PathBuf) -> Self {
|
2015-07-17 01:26:16 +08:00
|
|
|
|
|
|
|
BookItem {
|
|
|
|
name: name,
|
|
|
|
path: path,
|
|
|
|
sub_items: vec![],
|
2015-07-18 06:04:20 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-18 06:04:20 +08:00
|
|
|
fn push(&mut self, item: BookItem) {
|
|
|
|
self.sub_items.push(item);
|
|
|
|
}
|
|
|
|
|
2015-07-17 01:26:16 +08:00
|
|
|
}
|