Wire InfoCommand through as one real, runnable example
BambuRequest::Info(InfoCommand) is now live (was commented out) — examples/bambu_protocol_demo.rs constructs one, serializes it, and prints it next to Bambu's real wire JSON for comparison. Run it and copy this exact shape (proto message -> use it here -> add an enum variant) for every other command.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//! Run with: cargo run --example bambu_protocol_demo
|
||||
//!
|
||||
//! Proves the whole pipeline end to end: a message written in
|
||||
//! continuum-schemas' proto/bambulab/v1/request.proto, compiled by prost
|
||||
//! into a real Rust struct, wrapped in the hand-written BambuRequest enum,
|
||||
//! and serialized by plain serde — no protobuf binary encoding involved,
|
||||
//! since Bambu's actual wire format is JSON over MQTT.
|
||||
|
||||
use continuum_proxy::printer::BambuRequest;
|
||||
use continuum_types::bambulab::v1::InfoCommand;
|
||||
|
||||
fn main() {
|
||||
let request = BambuRequest::Info(InfoCommand {
|
||||
sequence_id: "0".to_string(),
|
||||
command: "get_version".to_string(),
|
||||
});
|
||||
|
||||
let actual = serde_json::to_string(&request).unwrap();
|
||||
let expected = r#"{"info":{"sequence_id":"0","command":"get_version"}}"#;
|
||||
|
||||
println!("generated: {actual}");
|
||||
println!("Bambu's real wire format: {expected}");
|
||||
println!("match: {}", actual == expected);
|
||||
}
|
||||
Reference in New Issue
Block a user