diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-11-19 23:46:51 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-11-19 23:46:51 +0100 |
| commit | 2e6e6244ccf73795d7d74cbc286fb0b43b404315 (patch) | |
| tree | 74357df3e7bd2a9b7955d912ef531d4b15e0520f /src/main.rs | |
| parent | 3a7bfd6bed9a932693588ca3cb61b101f8808783 (diff) | |
Switch to pdf-writer ⬆️
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 6bd5a9b4..715ee59f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ use std::cell::RefCell; -use std::fs::{read_to_string, File}; -use std::io::BufWriter; +use std::fs; use std::path::{Path, PathBuf}; use std::rc::Rc; @@ -35,7 +34,7 @@ fn main() -> anyhow::Result<()> { bail!("Source and destination path are the same."); } - let src = read_to_string(src_path).context("Failed to read from source file.")?; + let src = fs::read_to_string(src_path).context("Failed to read from source file.")?; let mut index = FsIndex::new(); index.search_dir("fonts"); @@ -72,10 +71,8 @@ fn main() -> anyhow::Result<()> { } } - let loader = loader.borrow(); - let file = File::create(&dest_path).context("Failed to create output file.")?; - let writer = BufWriter::new(file); - pdf::export(&layouts, &loader, writer).context("Failed to export pdf.")?; + let pdf_data = pdf::export(&layouts, &loader.borrow()); + fs::write(&dest_path, pdf_data).context("Failed to write PDF file.")?; Ok(()) } |
