Open jonas-schievink opened 3 years ago
You could add NewType wrappers around your buffer type and implement WriteTarget
on those.
The trait could be changed, too, but this seems to be a rather niche use case.
I'm not sure how I would turn a Box<Buffer>
into a Box<NewtypedBuffer>
though, at least when Box
is some library-provided smart pointer and not alloc::boxed::Box
. For example heapless' pool::singleton::Box
is generic over the pool it came from, not the pointee, so I don't see a convenient way to use a newtype there.
I have a use case where I'd like to reuse a buffer type for multiple different DMA operations that require different word sizes and alignments. Basically what I'd like to use as the buffer type is
Now I'd like to implement
WriteTarget
twice for this type, with au8
andi16
word. Unfortunately that doesn't work, since the word type is an associated type of theWriteTarget
trait. Maybe it would be better if it was a type parameter instead?