On Mon, 5 May 2025 at 14:45, Paolo Bonzini <bonz...@gnu.org> wrote:
>
> On 5/5/25 14:26, Manos Pitsidianakis wrote:
> >>     Something I do notice is that there's some inconsistency in
> >>     how we've structured things between the two devices, e.g.:
> >>
> >>     * the pl011 main source file is device.rs, but the hpet one
> >>       is hpet.rs


> >>     I think it would be good to figure out what we think is the
> >>     right, best style, for writing this kind of thing, and be
> >>     consistent. We have long standing problems in the C device
> >>     models where there are multiple different styles for how
> >>     we write them, and it would be good to try to aim for
> >>     more uniformity on the Rust side.
> >
> > The pl011 stuff was deliberate decisions:
> >
> > - device.rs vs pl011.rs: the device was written as a crate, so it's
> > essentially its own library, plus pl011/src/pl011.rs would be
> > redundant :)
>
> Right, I think Peter's comment was more about moving hpet.rs to
> device.rs, and merging PL011's device_class.rs into its device.rs.

Well, I don't actually have an opinion about which is better: I don't
know enough Rust to have a sense of what's more idiomatic or otherwise
preferable. My point is the more general one, that we should decide
(in all of these cases) which approach is going to work better for us
and apply that consistently, now that we have the benefit of having
written a couple of device models so we can see what each path looks like.

These initial devices are going to be the models that other people
(perhaps less familiar with Rust) are going to use as patterns when
they write other device models. Converging on a consistent structure
and way of writing devices now will help those future device authors
(including me!), I think.

-- PMM

Reply via email to