Re: [PATCH v4 5/7] rust: io: add `register!` macro
From: Danilo Krummrich
Date: Fri Jan 30 2026 - 12:22:29 EST
On Fri Jan 30, 2026 at 6:01 PM CET, Gary Guo wrote:
> `AsRef` won't work for `Io` which is a trait, unlike `Device` which is a type. A
> custom trait might work but that's more complex than what Alex purposed.
Are we sure about that? For instance, how do we determine the size of the I/O
operation in *_reg()? How can we trust that the type passed to *_reg() is valid
for an arbitrary bit pattern?
I mean, I'm not saying it's possible, but it seems that we end up with a couple
of safety requirements for the base register traits.
> I'm quite fond of the `io.read_reg(REGISTER_REF)` API suggested. It looks quite
> uniform with other I/O acceessor methods, except typed and with constant
> offsets.
It's just a nit, but I find it a bit icky that we have to have something like
the "_reg" suffix.