Re: [PATCH v9 2/5] rust: io: factor common I/O helpers into Io trait

From: Zhi Wang

Date: Sat Jan 17 2026 - 03:27:28 EST


On Fri, 16 Jan 2026 16:27:27 +0100
"Danilo Krummrich" <dakr@xxxxxxxxxx> wrote:

> (Cc: Markus)
>
> On Fri Jan 16, 2026 at 4:23 PM CET, Gary Guo wrote:
> > I wonder if we can keep all methods on `Io` trait. And then have
> > marker trait to represent capability on performing Io access.
> >
> > Something like:
> >
> > trait IoCapable<T> {}
> >
> > trait Io {
> > fn read8(&self, offset: usize) -> u8 where Self: IoCapable<u8>;
> > fn read16(&self, offset: usize) -> u16 where Self:
> > IoCapable<u16>; fn read32(&self, offset: usize) -> u32 where Self:
> > IoCapable<u32>; fn read64(&self, offset: usize) -> u64 where Self:
> > IoCapable<u64>; }
> >
> > Then you have a single (non-marker) trait and not a hierachy of
> > them.
>
> I think that is a great idea. I think it will also help with
> supporting I/O backends based on regmap.

Agreed. The IoCapable<T> marker trait approach is much cleaner and
solves the hierarchy complexity Alice pointed out.

I'll pick this up for v10. Thanks!

Z.