Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose choice of supported tonic version
The current way that tokio-vsock tries to support multiple tonic versions is problematic, and is a regression from 0.6.0 (which used `version = "0.12.0"` for the tonic dependency). tonic = { version = ">= 0.5.0, < 0.13.0", optional = true } This does not mean "tokio-vsock supports every tonic version from 0.5 through 0.12". It means "tokio-vsock supports a *single random* version of tonic between 0.5 and 0.12 according to Cargo's whim". Cargo does not expose any public way to control what choice of tonic would be used by this dependency. One possible way the problems would manifest (there are many) is: - Somebody writes a Cargo.toml depending on `tokio-vsock = { version = "0.6", features = ["tonic"] }` and `tonic = "0.11"`. In this situation Cargo (probably) resolves the tonic dependency inside tokio-vsock to 0.11 during local development. - They write Rust code counting on tonic 0.11's `Connected` impl to exist for `VsockStream`, such as by calling `.connect_info()` with `use tonic::transport::server::Connected;` referring to tonic 0.11. - They test their code extensively, locally and in CI, and everything works. - They publish to crates.io as a library. - Somebody else has a different project already using `tonic = "0.12"`, and they run `cargo add` to add a new dependency on the library from the previous step. - The library, despite having been extensively tested in CI, now does not compile because Cargo decided that it depends on tonic 0.11 and tokio-vsock 0.6 while tokio-vsock 0.6 now depends on tonic 0.12, and the necessary `Connected` impl is absent. This is a regression from tokio-vsock 0.6.0 because at least in 0.6.0 I could reliably use tokio-vsock with tonic 0.12 and write Rust code counting on that `Connected` impl to exist. In tokio-vsock master, there is no longer any way to use the `Connected` impl correctly. It may or may not exist from moment-to-moment depending on what else is going on in the project's dependency graph. This commit makes tokio-vsock correctly support a range of tonic versions. If built with `tokio-vsock = { features = ["tonic012"] }` then tonic 0.12's `Connected` trait is guaranteed to be implemented. Signed-off-by: David Tolnay <[email protected]>
- Loading branch information