[−][src]Function gen_epub_book::ops::parse_descriptor
pub fn parse_descriptor<R: Read>(
desc: &'static str,
from: &mut R,
separator: &str,
free_date: bool
) -> Result<Vec<BookElement>, Error>
Parse the whole descriptor with a specified separator with the specified rigidness, stopping at the first encountered error.
Uses BookElement::parse()
, so it inherits all errors from there,
adding only the error from splitting lines.
Filters out non-describing lines.
Examples
assert_eq!(parse_descriptor("string input", &mut &b"\ This is a very simple thing that should prove unproblematic to parse\n\ \n\ Name: Simple ePub demonstration\n\ Cover: cover.png\n\ \n\ Image-Content: simple/chapter_image.png\n\ Content: simple/ctnt.html\n\ \n\ Author: nabijaczleweli\n\ Date: 2017-02-08T15:30:18+01:00\n\ Language: en-GB\n"[..], ":", false), Ok(vec![ BookElement::Name("Simple ePub demonstration".to_string()), BookElement::Cover(PathBuf::from("cover.png")), BookElement::ImageContent(PathBuf::from("simple/chapter_image.png")), BookElement::Content(PathBuf::from("simple/ctnt.html")), BookElement::Author("nabijaczleweli".to_string()), BookElement::Date(DateTime::parse_from_rfc3339("2017-02-08T15:30:18+01:00").unwrap()), BookElement::Language("en-GB".to_string())]));