kRPC Client
Rust client for kRPC (Remote Procedure Calls for Kerbal Space Program).
Status
Work in progress. Bug-reports and contributions welcome. All procedures seem to work, but more testing is needed. Streams work, but Events are still on the way.
= { = "https://github.com/kladd/krpc-client" }
Examples
Greet the crew with standard procedure calls.
let client = new.unwrap;
let sc = new;
// Check out our vessel.
let ship = sc.get_active_vessel?;
// Greet the crew.
match ship.get_crew?.first ;
Using Streams
Keep track of time with streams.
let client = new?;
let space_center = new;
// Set up a stream.
let ut_stream = space_center.get_ut_stream?;
ut_stream.set_rate?;
// Wait for updates, and print the current value.
for _ in 0..10
Using Custom Service Definitions
If you have a set of custom service definitions, for example from KRPC.MechJeb you can put them all in a directory and point the KRPC_SERVICES environment variable to it at build time, this crate will generate a rust client implementation for them.
Important: If you do this you have to provide all service definitions, even the ones this crate usually includes
Features
fmt(default): Format generated services. Remove for a quicker build producing an unreadable file.tokio: Replace all blocking functions with async functions using the tokio runtime
Hacking
krpc-client/client.rscontains basic connection, request, and response handling.krpc-client/lib.rsdeclares traits for encoding and decoding RPC types.krpc_build(used bykrpc-client/build.rs), generates RPC types and procedures from definitions inservice_definitions/*.json, and generates implementations of the encoding and decoding traits declared inkrpc-client/lib.rs.