[pbs-devel] [PATCH v3 pxar 03/58] decoder: add method to read payload references
Christian Ebner
c.ebner at proxmox.com
Thu Mar 28 13:36:12 CET 2024
This is in preparation for reading payloads from a dedicated payload
input stream.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 2:
- decode based on format struct, instead of reading u64 and constructing
object
src/decoder/mod.rs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs
index d1fb911..cc50e4f 100644
--- a/src/decoder/mod.rs
+++ b/src/decoder/mod.rs
@@ -661,6 +661,17 @@ impl<I: SeqRead> DecoderImpl<I> {
async fn read_quota_project_id(&mut self) -> io::Result<format::QuotaProjectId> {
self.read_simple_entry("quota project id").await
}
+
+ async fn read_payload_ref(&mut self) -> io::Result<format::PayloadRef> {
+ let content_size =
+ usize::try_from(self.current_header.content_size()).map_err(io_err_other)?;
+
+ if content_size != 2 * size_of::<u64>() {
+ io_bail!("bad payload reference entry");
+ }
+
+ seq_read_entry(&mut self.input).await
+ }
}
/// Reader for file contents inside a pxar archive.
--
2.39.2
More information about the pbs-devel
mailing list