Down from 29 warnings to 2, in the spirit of 4ab95ff.
The doc warnings were all one mistake made repeatedly: a paragraph wrapped so
that a line *began* with `- ` or `+ `, which rustdoc reads as a markdown list
marker and the following lines as unindented continuations. The prose always
meant an em-dash. Fixed by moving the dash to the end of the previous line and
re-wrapping; not one word changed, which is the point - these comments record
things confirmed against real printers and are worth more than the warning.
The genuine lists just had their continuations de-indented and stayed lists.
The code ones are `match x { V(v) => .., _ => {} }` to `if let`, and nested
`if let Some(x) = .. { if cond { .. } }` to a let-chain. None had an `else`,
so each is the same control flow written once instead of twice.
Two warnings are left deliberately, because fixing them is not cosmetic:
`AmsTray` (544 bytes against 32) and `BambuReport` (984 against 120) both have
one variant far larger than the rest. The fix clippy wants is a `Box`, which
changes how every reader of those enums is written and puts an allocation on
the push_status path that currently has none. Worth measuring before doing,
not worth doing to silence a warning.
51 tests still pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
//! Run with: cargo run --example auto_connect_bambu
|
|
//!
|
|
//! For each Bambu printer in printers.toml, makes sure it has a working
|
|
//! certificate, auto-pinning one via trust-on-first-connect if the
|
|
//! bundled CA doesn't verify - the exact same `ensure_trusted` step
|
|
//! `BambuPrinter::connect()` runs before opening MQTT, isolated here so
|
|
//! you can check/establish trust without needing a full MQTT handshake to
|
|
//! succeed too. Safe to run repeatedly - a printer that's already pinned
|
|
//! (certs/pinned/<serial number>.pem) just gets re-verified against its
|
|
//! pin, no network trust decision is made again.
|
|
|
|
use continuum_proxy::fleet;
|
|
use continuum_proxy::printer::PrinterHandle;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let mut printers = fleet::load(std::path::Path::new("printers.toml"))?;
|
|
let cert_dir = std::path::Path::new("certs/pinned");
|
|
|
|
for printer in &mut printers {
|
|
if let PrinterHandle::Bambu(bambu) = printer {
|
|
report(&bambu.ensure_trusted(cert_dir))
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn report(result: &anyhow::Result<()>) {
|
|
match result {
|
|
Ok(()) => println!("connected"),
|
|
Err(err) => println!("failed: {err}"),
|
|
}
|
|
}
|