[pbs-devel] [RFC pxar 1/20] fix #3174: encoder: impl fn new for LinkOffset

Christian Ebner c.ebner at proxmox.com
Wed Sep 27 14:26:03 CEST 2023


> On 27.09.2023 14:08 CEST Wolfgang Bumiller <w.bumiller at proxmox.com> wrote:
> 
>  
> On Fri, Sep 22, 2023 at 09:16:02AM +0200, Christian Ebner wrote:
> > Allows to generate a new LinkOffset for storing the offset of regular
> > files in the backup catalog, based on the provided archiver position.
> > 
> > Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> > ---
> >  src/encoder/mod.rs | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
> > index 0d342ec..710ed98 100644
> > --- a/src/encoder/mod.rs
> > +++ b/src/encoder/mod.rs
> > @@ -31,6 +31,12 @@ pub use sync::Encoder;
> >  pub struct LinkOffset(u64);
> >  
> >  impl LinkOffset {
> > +    /// Create a new link from the raw byte offset.
> > +    #[inline]
> > +    pub fn new(raw: u64) -> Self {
> 
> Not very happy about that. It was meant to be an opaque type that you
> can't just create easily.
> But oh well... if we need it...
> Better than using u64 directly.

Might it be worth to create dedicated types or enums for the different offsets
needed? I do need some way to hande the different offsets and this just seemed
better than some raw u64, in order to have at least some type checking.

> 
> > +        Self(raw)
> > +    }
> > +
> >      /// Get the raw byte offset of this link.
> >      #[inline]
> >      pub fn raw(self) -> u64 {
> > -- 
> > 2.39.2





More information about the pbs-devel mailing list