uefi-rs icon indicating copy to clipboard operation
uefi-rs copied to clipboard

Add an API for constructing device paths

Open nicholasbishop opened this issue 2 years ago • 1 comments

Right now the device path API we have is mostly useful for reading existing paths rather than constructing new ones. I don't have a clear idea yet of what a good construction API would look like, but it would be nice to have something better than just filling in a raw array of bytes and casting.

nicholasbishop avatar Apr 30 '22 00:04 nicholasbishop

Maybe using the builder pattern, but the builder is initially passed in a raw buffer of bytes where it will build the device path? Alternatively, we could get rid of the buffer by using alloc in the builder code.

The builder could have methods for adding a new DeviceInstance sub-structure, which returns a sub-builder for constructing this sub-structure. When the user adds an end of instance marker, we finalize this builder and return a reference to the parent builder. When the user adds an "end of hardware" device path, the top-level builder is consumed and returns a reference to the new device path array.

GabrielMajeri avatar May 01 '22 13:05 GabrielMajeri