volaris_tools/header/
dump.rs

1//! This provides functionality for dumping a header that adheres to the volaris format.
2
3use super::Error;
4use std::cell::RefCell;
5use std::io::{Read, Seek, Write};
6
7use corecrypto::header::Header;
8
9pub struct Request<'a, R, W>
10where
11    R: Read + Seek,
12    W: Write + Seek,
13{
14    pub reader: &'a RefCell<R>,
15    pub writer: &'a RefCell<W>,
16}
17
18pub fn execute<R, W>(req: Request<'_, R, W>) -> Result<(), Error>
19where
20    R: Read + Seek,
21    W: Write + Seek,
22{
23    let (header, _) =
24        Header::deserialize(&mut *req.reader.borrow_mut()).map_err(|_| Error::InvalidFile)?;
25
26    header
27        .write(&mut *req.writer.borrow_mut())
28        .map_err(|_| Error::Write)?;
29
30    Ok(())
31}