8e5d85202f
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.
25 lines
929 B
Rust
25 lines
929 B
Rust
//! 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);
|
|
}
|