Re: [PATCH 03/14] hash: use uint32_t for object_id algorithm
- From
Ezekiel Newren <ezekielnewren@gmail.com>
- Date
- Oct 28, 2025, 18:28 UTC
- Message-ID
- <CAH=ZcbCWNiu5OqJO1m-1QYrZRXFydD5Pt7mg_1BhOwVHu_PKJQ@mail.gmail.com>
- In-Reply-To
- <aQCKCfuaEKBArD-g@pks.im>
On Tue, Oct 28, 2025 at 3:17 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 10 quoted lines
> > On Mon, Oct 27, 2025 at 12:43:53AM +0000, brian m. carlson wrote: > > We currently use an int for this value, but we'll define this structure > > from Rust in a future commit and we want to ensure that our data types > > are exactly identical. To make that possible, use a uint32_t for the > > hash algorithm. > > An alternative would be to introduce an enum and set up bindgen so that > we can pull this enum into Rust. I'd personally favor that over using an > uint32_t as it conveys way more meaning. Have you considered this?
I think uint32_t is appropriate here over an enum because this value will also exist on disk. An enum in Rust is really only safe if it exists exclusively in memory, and is untouched by C. Later in this patch series there is a function that creates an enum from a u32. I agree with Brian's design choice here.