Re: [PATCH v9 2/5] rust: io: factor common I/O helpers into Io trait
From: Danilo Krummrich
Date: Fri Jan 16 2026 - 10:27:35 EST
(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.