Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create KRPC servicee correctly #3

Open
ThePerkinrex opened this issue May 18, 2020 · 6 comments
Open

Cannot create KRPC servicee correctly #3

ThePerkinrex opened this issue May 18, 2020 · 6 comments

Comments

@ThePerkinrex
Copy link

When I take the KRPC.json from the krpc directory, it creates some code that cannot be compiled. If there is another way to use that service, that would be awesome.

error[E0106]: missing lifetime specifier
    --> src/krpc/krpc.rs:1143:38
     |
1143 | pub fn get_client_id() -> CallHandle<&[u8]> {
     |                                      ^ help: consider giving it a 'static lifetime: `&'static`
     |
     = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from

error[E0106]: missing lifetime specifier
    --> src/krpc/krpc.rs:1280:41
     |
1280 | pub fn get_clients() -> CallHandle<Vec<(&[u8], String, String)>> {
     |                                         ^ help: consider giving it a 'static lifetime: `&'static`
     |
     = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from

error: aborting due to 2 previous errors

These are compiler errors given, maybe they're useful.

If I find how to fix this, I will let you know

@ThePerkinrex
Copy link
Author

If those problems are fixed (adding a static lifetime), there are more errors the compiler spits out

error[E0277]: the trait bound `krpc_mars::krpc::Event: krpc_mars::codec::RPCExtractable` is not satisfied
   --> src/krpc/krpc.rs:119:5
    |
119 |     CallHandle::new(proc_call)
    |     ^^^^^^^^^^^^^^^ the trait `krpc_mars::codec::RPCExtractable` is not implemented for `krpc_mars::krpc::Event`
    |
    = note: required by `krpc_mars::CallHandle::<T>::new`

error[E0599]: no method named `encode_to_bytes` found for struct `krpc_mars::krpc::ProcedureCall` in the current scope
   --> src/krpc/krpc.rs:132:27
    |
132 |     arg0.set_value(p_call.encode_to_bytes().unwrap());
    |                           ^^^^^^^^^^^^^^^ method not found in `krpc_mars::krpc::ProcedureCall`

error[E0277]: the trait bound `krpc_mars::krpc::Stream: krpc_mars::codec::RPCExtractable` is not satisfied
   --> src/krpc/krpc.rs:141:5
    |
141 |     CallHandle::new(proc_call)
    |     ^^^^^^^^^^^^^^^ the trait `krpc_mars::codec::RPCExtractable` is not implemented for `krpc_mars::krpc::Stream`
    |
    = note: required by `krpc_mars::CallHandle::<T>::new`

error[E0599]: no method named `encode_to_bytes` found for struct `krpc_mars::krpc::ProcedureCall` in the current scope
   --> src/krpc/krpc.rs:308:27
    |
308 |     arg0.set_value(p_call.encode_to_bytes().unwrap());
    |                           ^^^^^^^^^^^^^^^ method not found in `krpc_mars::krpc::ProcedureCall`

error[E0599]: no method named `encode_to_bytes` found for reference `&std::collections::HashSet<krpc::krpc::Expression>` in the current scope
   --> src/krpc/krpc.rs:532:29
    |
532 |     arg0.set_value(p_values.encode_to_bytes().unwrap());
    |                             ^^^^^^^^^^^^^^^ method not found in `&std::collections::HashSet<krpc::krpc::Expression>`

error[E0599]: no method named `encode_to_bytes` found for reference `&std::collections::HashMap<std::string::String, krpc::krpc::Expression>` in the current scope
   --> src/krpc/krpc.rs:725:27
    |
725 |     arg1.set_value(p_args.encode_to_bytes().unwrap());
    |                           ^^^^^^^^^^^^^^^ method not found in `&std::collections::HashMap<std::string::String, krpc::krpc::Expression>`

error[E0277]: the trait bound `&[u8]: krpc_mars::codec::RPCExtractable` is not satisfied
    --> src/krpc/krpc.rs:1148:5
     |
1148 |     CallHandle::new(proc_call)
     |     ^^^^^^^^^^^^^^^ the trait `krpc_mars::codec::RPCExtractable` is not implemented for `&[u8]`
     |
     = note: required by `krpc_mars::CallHandle::<T>::new`

error[E0277]: the trait bound `krpc_mars::krpc::Services: krpc_mars::codec::RPCExtractable` is not satisfied
    --> src/krpc/krpc.rs:1166:5
     |
1166 |     CallHandle::new(proc_call)
     |     ^^^^^^^^^^^^^^^ the trait `krpc_mars::codec::RPCExtractable` is not implemented for `krpc_mars::krpc::Services`
     |
     = note: required by `krpc_mars::CallHandle::<T>::new`

error[E0277]: the trait bound `krpc_mars::krpc::Status: krpc_mars::codec::RPCExtractable` is not satisfied
    --> src/krpc/krpc.rs:1175:5
     |
1175 |     CallHandle::new(proc_call)
     |     ^^^^^^^^^^^^^^^ the trait `krpc_mars::codec::RPCExtractable` is not implemented for `krpc_mars::krpc::Status`
     |
     = note: required by `krpc_mars::CallHandle::<T>::new`

error[E0277]: the trait bound `&[u8]: krpc_mars::codec::RPCExtractable` is not satisfied
    --> src/krpc/krpc.rs:1285:5
     |
1285 |     CallHandle::new(proc_call)
     |     ^^^^^^^^^^^^^^^ the trait `krpc_mars::codec::RPCExtractable` is not implemented for `&[u8]`
     |
     = note: required because of the requirements on the impl of `krpc_mars::codec::RPCExtractable` for `(&[u8], std::string::String, std::string::String)`
     = note: required because of the requirements on the impl of `krpc_mars::codec::RPCExtractable` for `std::vec::Vec<(&[u8], std::string::String, std::string::String)>`
     = note: required by `krpc_mars::CallHandle::<T>::new`

error: aborting due to 10 previous errors

@ThePerkinrex
Copy link
Author

Maybe this is more suitable for the krpc_mars repo, but as this is code generated from this one, I'm putting it in this one first

@Cahu
Copy link
Owner

Cahu commented May 19, 2020

Hi,
The KRPC.json file contains definitions that are only useful to dynamic languages such as python (although I haven't played the game in a while and this may have changed) and you should ignore it, as described in the README of https://github.com/Cahu/krpc-mars.
You should be able to generate the code for files like KRPC.<service name>.json.

@ThePerkinrex
Copy link
Author

Ok, perfect. I wondered whether I could use that service, because it has some useful procedures, such as knowing if the game is paused or if you're in flight

@Cahu
Copy link
Owner

Cahu commented May 19, 2020

Perhaps #2 will work for you. I haven't had the time to test this patch.

@ThePerkinrex
Copy link
Author

I will check it out, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants