aboutsummaryrefslogtreecommitdiffstats
path: root/src/epub.rs
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2021-03-28 01:35:32 -0700
committerJames Campos <james.r.campos@gmail.com>2021-03-28 01:35:32 -0700
commit9809dc99acd2ff65358b7bbe3c1be6c303f558b7 (patch)
tree0f84c42cf6d7607ffca344d83109957166b5a9de /src/epub.rs
parentb79c05312df99115d475b69eabd5961e8a4e485f (diff)
downloadbk-9809dc99acd2ff65358b7bbe3c1be6c303f558b7.tar.gz
remove anyhow
doesn't work on None
Diffstat (limited to 'src/epub.rs')
-rw-r--r--src/epub.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/epub.rs b/src/epub.rs
index 66d1077..a52c9d0 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -1,7 +1,10 @@
-use anyhow::Result;
use crossterm::style::{Attribute, Attributes};
use roxmltree::{Document, Node, ParsingOptions};
-use std::{collections::HashMap, fs::File, io::Read};
+use std::{
+ collections::HashMap,
+ fs::File,
+ io::{self, Read},
+};
pub struct Chapter {
pub title: String,
@@ -24,7 +27,7 @@ pub struct Epub {
}
impl Epub {
- pub fn new(path: &str, meta: bool) -> Result<Self> {
+ pub fn new(path: &str, meta: bool) -> io::Result<Self> {
let file = File::open(path)?;
let mut epub = Epub {
container: zip::ZipArchive::new(file)?,
@@ -33,7 +36,7 @@ impl Epub {
links: HashMap::new(),
meta: String::new(),
};
- let chapters = epub.get_spine()?;
+ let chapters = epub.get_spine();
if !meta {
epub.get_chapters(chapters);
}
@@ -85,7 +88,7 @@ impl Epub {
self.chapters.push(c);
}
}
- fn get_spine(&mut self) -> Result<Vec<(String, String)>> {
+ fn get_spine(&mut self) -> Vec<(String, String)> {
let xml = self.get_text("META-INF/container.xml");
let doc = Document::parse(&xml).unwrap();
let path = doc
@@ -141,7 +144,7 @@ impl Epub {
let doc = Document::parse(&xml).unwrap();
epub2(doc, &mut nav);
}
- Ok(spine_node
+ spine_node
.children()
.filter(Node::is_element)
.enumerate()
@@ -151,7 +154,7 @@ impl Epub {
let label = nav.remove(path).unwrap_or_else(|| i.to_string());
(label, path.to_string())
})
- .collect())
+ .collect()
}
}