vmsilo fork of vhost rust libraries
In order to allow zero-cost exchanging of the concrete bitmap and vring types, a lot of the generic code required using a tuple of `<VringType, BitmapType>` for parameterizing the impl's. Once code is also oblivious of the concrete backend (and a lot of code is), this tuple turns into a triplet. Juggling these three single letter generic parameters while making sure that all the type constraints (that are also changing depending on the abstraction layer) does not feel very ergonomic. While one can argue that within this crate, this would be fine since people probably know the internals, the design choice is leaking out into every consumer of vhost-user-backend. Instead of just being able to reference "some backend" one needs to copy a lot of boilerplate code for also passing the other type parameters (again, while making sure that all the constraints are met). Instead, this commit changes things to utilize associated types [1]. This makes the Bitmap and Vring types part of the backend trait and requires the implementations to spell them out. Code that just wants to use the backend without needing to know the details can now just use the trait without needing to specify the Bitmap and Vring types again. Where needed, restricting Bitmap and Vring further is still possible (though one no longer needs to copy all the existing restrictions and can keep the code more maintainable by only listing new ones). Overall, my main target was to improve the ergonomics of the consumers of the crate. But I think the change also improves the readability and maintainability within this crate. Combined, this hopefully justifies the small code breakage in consumers. No functional changes intended. No change in type flexibility intended. BREAKING CHANGE, consumers of the lib will need to adjust their code (but it should improve the general readability). Signed-off-by: Erik Schilling <erik.schilling@linaro.org> [1] https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types |
||
|---|---|---|
| .buildkite | ||
| .cargo | ||
| .github | ||
| crates | ||
| rust-vmm-ci@665f31f4b4 | ||
| .gitignore | ||
| .gitmodules | ||
| Cargo.toml | ||
| CODEOWNERS | ||
| coverage_config_aarch64.json | ||
| coverage_config_x86_64.json | ||
| LICENSE | ||
| LICENSE-BSD-3-Clause | ||
| README.md | ||
vhost
The vhost workspace hosts libraries related to the vhost and vhost-user
protocols. It currently consists of the following crates:
vhost-> A pure rust library for vDPA, vhost and vhost-user.vhost-user-backend-> It provides a framework to implementvhost-userbackend services.