refactor(replay/recorder): write directly to zip file

This commit is contained in:
Ryan 2025-03-14 16:50:40 -04:00
parent a957aaeaec
commit 3e672c4d1a
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

View File

@ -68,11 +68,12 @@ impl Recorder {
} }
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> { pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
let mut data = Vec::with_capacity(raw_packet.len() + 8); self.zip_writer.write_all(
data.extend(TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes()); &TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes(),
data.extend(TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes()); )?;
data.extend(raw_packet); self.zip_writer
self.zip_writer.write_all(&data)?; .write_all(&TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes())?;
self.zip_writer.write_all(raw_packet)?;
Ok(()) Ok(())
} }