1extern crate alloc;
6
7use alloc::vec::Vec;
8use core::result::Result;
9use std::io::Cursor;
10use std::path::Path;
11
12use crate::book::{EpubBook, EpubBookOptions};
13use crate::error::EpubError;
14
15pub async fn open_epub_file_async<P: AsRef<Path>>(
19 path: P,
20) -> Result<EpubBook<Cursor<Vec<u8>>>, EpubError> {
21 open_epub_file_async_with_options(path, EpubBookOptions::default()).await
22}
23
24pub async fn open_epub_file_async_with_options<P: AsRef<Path>>(
26 path: P,
27 options: EpubBookOptions,
28) -> Result<EpubBook<Cursor<Vec<u8>>>, EpubError> {
29 let bytes = tokio::fs::read(path)
30 .await
31 .map_err(|e| EpubError::Io(e.to_string()))?;
32 EpubBook::from_reader_with_options(Cursor::new(bytes), options)
33}