bc4ee8690a
Reconsidered after actually feeling the friction: this data is JSON over MQTT (not binary protobuf), only continuum-proxy ever parses it (raw vendor wire format, never crosses into TS), so none of protobuf's actual value (cross-language codegen, binary wire efficiency) applied here. Every gotcha hit while building this (field_attribute's oneof/variant path collision, needing .bambulab-scoped type_attribute calls, explicit #[serde(default)] per not-always-present field) came from forcing prost-build's codegen model onto a plain-JSON, Rust-only use case. Verified the replacement is strictly simpler, not just smaller: a hand-written struct's Option<T> field needs zero extra attributes to handle a missing JSON key (prost's generated String needed an explicit field_attribute call per field), and #[serde(flatten)] on a hand-written field has no ambiguity at all (prost-build's oneof/variant path collision doesn't exist without prost-build's codegen in the picture). The replacement lives in continuum-proxy: src/printer/bambu_commands/. continuum.v1 is unaffected — that schema is genuinely cross-language and proto still earns its keep there.
28 lines
892 B
Rust
28 lines
892 B
Rust
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let proto_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../proto")
|
|
.canonicalize()
|
|
.expect("proto root must exist");
|
|
|
|
let proto_files = [
|
|
proto_root.join("continuum/v1/material.proto"),
|
|
proto_root.join("continuum/v1/print_params.proto"),
|
|
proto_root.join("continuum/v1/template.proto"),
|
|
proto_root.join("continuum/v1/print_job.proto"),
|
|
];
|
|
|
|
for file in &proto_files {
|
|
println!("cargo:rerun-if-changed={}", file.display());
|
|
}
|
|
|
|
let mut config = prost_build::Config::new();
|
|
config.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]");
|
|
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");
|
|
|
|
config
|
|
.compile_protos(&proto_files, &[proto_root])
|
|
.expect("failed to compile continuum .proto sources");
|
|
}
|