gschup / bevy_ggrs

Bevy plugin for the GGRS P2P rollback networking library.
Other
302 stars 41 forks source link

Trouble implementing the Config trait #24

Closed paul-english closed 2 years ago

paul-english commented 2 years ago

Describe the bug I'm having trouble implementing Config and wonder if something unusual is being required by this trait or some of it's dependencies. Maybe the bytemuck version fixing, though I don't know for sure.

error[E0599]: the function or associated item `new` exists for struct `GGRSPlugin<GGRSConfig>`, but its trait bounds were not satisfied
   --> src/main.rs:79:31
    |
63  | pub struct GGRSConfig;
    | ---------------------- doesn't satisfy `GGRSConfig: ggrs::Config`
...
79  |     GGRSPlugin::<GGRSConfig>::new()
    |                               ^^^ function or associated item cannot be called on `GGRSPlugin<GGRSConfig>` due to unsatisfied trait bounds
    |
    = note: the following trait bounds were not satisfied:
            `GGRSConfig: ggrs::Config`
note: the following trait must be implemented
   --> /Users/paul/.cargo/git/checkouts/ggrs-151f8bd9eb75dc5d/37b83c3/src/lib.rs:178:1
    |
178 | / pub trait Config: 'static + Send + Sync {
179 | |     /// The input type for a session. This is the only game-related data
180 | |     /// transmitted over the network.
181 | |     ///
...   |
193 | |     type Address: Clone + PartialEq + Eq + Hash + Send + Sync;
194 | | }
    | |_^

error[E0277]: the trait bound `GGRSConfig: ggrs::Config` is not satisfied
  --> src/main.rs:79:5
   |
79 |     GGRSPlugin::<GGRSConfig>::new()
   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ggrs::Config` is not implemented for `GGRSConfig`
   |
note: required by a bound in `GGRSPlugin`
  --> /Users/paul/.cargo/git/checkouts/bevy_ggrs-8ac41541d9ef4c9f/928376d/src/lib.rs:73:26
   |
73 | pub struct GGRSPlugin<T: Config + Send + Sync> {
   |                          ^^^^^^ required by this bound in `GGRSPlugin`

To Reproduce Steps to reproduce the behavior:

  1. Update bevy_ggrs_demo to use bevy 0.7, and update ggrs and bevy_ggrs to git based versions.
  2. Try to run the project with cargo run

Updated Cargo.toml in the bevy_ggrs_demo:

[package]
name = "bevy_ggrs_demo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy_asset_loader = "0.8"
bevy = "0.7"
bytemuck = {version="1.7.3", features= ["derive"]}
ggrs = { git = "https://github.com/gschup/ggrs", features=["sync-send"], rev="37b83c3478114e2876c133f255bc00b29c6af796" }
bevy_ggrs = {git = "https://github.com/gschup/bevy_ggrs", rev="928376df6b37f391ef6593e0355ba5a737ec1492"}
matchbox_socket = { git = "https://github.com/johanhelsing/matchbox", features = ["ggrs-socket"], rev="50c1e69e9f1c0f1e07e0ffd5161db0ce3f9267b5" }
log = "0.4"

[target.'cfg(target_arch = "wasm32")'.dependencies]
ggrs = { git = "https://github.com/gschup/ggrs", features=["sync-send", "wasm-bindgen"], rev="37b83c3478114e2876c133f255bc00b29c6af796" }
bevy_ggrs = {git = "https://github.com/gschup/bevy_ggrs", features=["wasm-bindgen"], rev="928376df6b37f391ef6593e0355ba5a737ec1492"}
bevy-web-resizer = "0.1.0"
web-sys = "0.3"

Expected behavior Errors only related to the bevy 0.6 -> 0.7 upgrade.

Desktop (please complete the following information):

paul-english commented 2 years ago

I've recreated the trait issue I see in my other project with this fork of bevy_ggrs_demo: https://github.com/gschup/bevy_ggrs_demo/compare/main...paul-english:bevy_ggrs_demo:main

Note: there are predictably more errors, though they all looked related to bevy 0.6 -> 0.7 differences.

In my local project I see just the issue the following trait bounds were not satisfied: GGRSConfig: ggrs::Config. The Config implementation is the same as your examples so I can only guess that maybe rustc is seeing perhaps two different versions of the Pod and Zeroable trait.

gschup commented 2 years ago

Sorry for the late answer. This seems like a dependency version issue of your project. Since bevy has already moved forward to 0.8 and bevy_ggrs has been updated accordingly, I am closing this issue.