Drop proto/bambulab/ — plain hand-written Rust structs instead

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.
This commit is contained in:
2026-08-28 22:48:48 +00:00
parent f2f7d07b77
commit ffcfe0d349
7 changed files with 17 additions and 121 deletions
+15 -17
View File
@@ -8,20 +8,18 @@ pub use continuum::v1::{
MaterialProfile, PrintJob, PrintJobStatus, PrintParameters, Template,
};
pub mod bambulab {
// common.proto and bambulab/v2/*.proto have no messages yet, so
// there's nothing for prost to emit for them — `include!` against a
// nonexistent file breaks the build. Uncomment each once it has real
// content:
//
// include!(concat!(env!("OUT_DIR"), "/bambulab.rs")); // common.proto's messages
pub mod v1 {
// request.proto + report.proto both declare `package bambulab.v1;`,
// so prost combines them into one output file, regardless of which
// input file each message came from.
include!(concat!(env!("OUT_DIR"), "/bambulab.v1.rs"));
}
// pub mod v2 {
// include!(concat!(env!("OUT_DIR"), "/bambulab.v2.rs"));
// }
}
// Bambu's raw MQTT command/report structs are NOT modeled here — they're
// plain hand-written Rust + serde in continuum-proxy's
// src/printer/bambu_commands/, not proto. That data is JSON-over-MQTT
// (not binary protobuf), and only continuum-proxy ever needs to parse it
// — none of protobuf's actual value (cross-language codegen, binary wire
// efficiency) applies, and forcing it through prost-build's codegen model
// anyway produced real, avoidable friction (see this crate's git history
// for the specifics: a field/variant attribute-matching collision on
// `oneof`, needing package-scoped `type_attribute` calls, explicit
// `field_attribute(..., "#[serde(default)]")` for fields that aren't
// always present — every one of these disappears with a hand-written
// struct, where `Option<T>` and `#[serde(flatten)]` just work with zero
// configuration). Proto stays for continuum.v1 above, which — unlike
// this — is a schema we designed ourselves and that both TS and Rust
// genuinely need.