Descriptor chain walking.
Although walking these chains feels similar to using an iterator, the chains do not directly
std::iter::Iterator trait as iterator composition works against being able to
then convert a
ReadableChain into a
WritableChain. An iterator can be built on top of
these interfaces, but it has not been done here yet.
In addition to walking byte ranges via the
next or [
(ReadableChain::next_with_limit) methods, the
Read and [
(std::io::Write) traits are implemented for
When using the
std::io::Write interface for the
WritableChain the amount written is
tracked, alleviating the need to manually perform
Although not always appropriate depending on the particular virtio device, the
Write interfaces are therefore the preferred way to
manipulate the chains.
The requirement from the virtio specification that all readable descriptors occur before all
writable descriptors is enforced here, with explicit types that indicate what is being walked.
Transitioning from the
ReadableChain to the
WritableChain is an explicit operation that
allows for optional checking to ensure all readable descriptors have been consumed. This allows
devices to easily check if the driver is violating any protocol assumptions on descriptor
- Access the readable portion of a descriptor chain.
- Access the writable portion of a descriptor chain.
- Errors resulting from completing a chain.
- Errors from walking a descriptor chain.