midi-msg
midi-msg copied to clipboard
Vec-less API for embedded usage?
I'm interested in using midi-msg for an embedded MIDI project, but I see that the core MidiMsg
type relies on Vec<u8>
for the internal representation of arbitrary-length message types, such as sysex messages.
Do you have any thoughts on what it might take to implement a type that has no_std
support for all message types?
I could see two ways this might work:
- Replace
MidiMsg
withMidiMsg<'a>
, and any internal use ofVec<u8>
would be changed to&'a [u8]
, referring to a slice of the input buffer. I'm not sure if this would work in general - are there cases where the outputVec<u8>
is not a contiguous slice of the input buffer? If every output type is a contiguous sample of the input, this seems like the best approach - no memory overhead! - If the above won't work, replace
MidiMsg
withMidiMsg<Buffer>
, whereBuffer
could be set to something likestd::Vec<u8>
orheapless::Vec<u8,N>
, unified by a common (crate-specific) trait, and add aMessageTooLong
constructor to theParseError
type (which would not ever occur while usingstd::Vec<u8>
I'm not sure if this would work with your design intentions for the library, but I'm probably going to have to add this functionality in any case, so figured I would check if there was some approach that would be upstreamable.