5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2025-03-11 20:58:47 +03:00

encoder: add payload position capability

Allows to read the current payload offset from the dedicated payload
input stream. This is required to get the current offset for calculation
of forced boundaries in the proxmox-backup-client, when injecting reused
payload chunks into the payload stream.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2024-03-13 09:00:21 +01:00
parent 15fbb28319
commit 2c1daa75fa
3 changed files with 14 additions and 0 deletions

View File

@ -75,6 +75,11 @@ impl<'a, T: SeqWrite + 'a> Encoder<'a, T> {
})
}
/// Get current position for payload stream
pub fn payload_position(&self) -> io::Result<PayloadOffset> {
self.inner.payload_position()
}
// /// Convenience shortcut to add a *regular* file by path including its contents to the archive.
// pub async fn add_file<P, F>(
// &mut self,

View File

@ -524,6 +524,10 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
Ok(offset)
}
pub fn payload_position(&self) -> io::Result<PayloadOffset> {
Ok(PayloadOffset(self.state()?.payload_position()))
}
/// Encode a payload reference pointing to given offset in the separate payload output
///
/// Returns a file offset usable with `add_hardlink` or with error if the encoder instance has

View File

@ -97,6 +97,11 @@ impl<'a, T: SeqWrite + 'a> Encoder<'a, T> {
))
}
/// Get current payload position for payload stream
pub fn payload_position(&self) -> io::Result<PayloadOffset> {
self.inner.payload_position()
}
/// Encode a payload reference pointing to given offset in the separate payload output
///
/// Returns with error if the encoder instance has no separate payload output or encoding