//! Run with: cargo run --example auto_connect_bambu //! //! The "smooth, no manual steps" version of test_bambu_certs + //! fetch_bambu_cert combined: 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. Safe to run //! repeatedly - a printer that's already pinned (certs/pinned/.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 { match printer { PrinterHandle::BambuV1(bambu) => report(&bambu.ensure_trusted(cert_dir)), PrinterHandle::BambuV2(bambu) => report(&bambu.ensure_trusted(cert_dir)), _ => {} } } Ok(()) } fn report(result: &anyhow::Result<()>) { match result { Ok(()) => println!("connected"), Err(err) => println!("failed: {err}"), } }