uefi-rs
uefi-rs copied to clipboard
Add an API for constructing device paths
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.
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.