[pbs-devel] [RFC pxar 1/20] fix #3174: encoder: impl fn new for LinkOffset
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Sep 28 08:49:40 CEST 2023
On Wed, Sep 27, 2023 at 02:26:03PM +0200, Christian Ebner wrote:
> > 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.
For different purposes I would *prefer* different types, if
possible.
Since your "new" offsets come from a new method (`app_appendix`), it
should IMO be possible.
That way it's clear that you shouldn't use these offsets for eg.
`add_hardlink` and you bind the value to a purpose via a type.
More information about the pbs-devel
mailing list