pub mod capture;
pub mod config;
pub mod display;
pub mod firmware;
pub mod flash;
pub mod ingest;
pub mod model;
pub mod params;
pub mod probe;
pub mod provision;
pub mod restore;
pub mod screen;
pub mod upgrade;
pub mod util;
pub use colorlight as protocol;
pub use panelspec;
pub use panelspec::{read_library, Loader};
pub use rcvbp;
pub use receivers;
use receivers::CardModel;
use anyhow::{Context, Result};
use std::io::{IsTerminal, Write};
#[derive(Clone, Debug)]
pub struct Ctx {
pub iface: String,
pub width: u16,
pub height: u16,
pub order: protocol::ColorOrder,
pub brightness: u8,
pub model: Option<&'static CardModel>,
}
impl Ctx {
pub fn model(&self) -> Result<&'static CardModel> {
self.model
.context("no card model: no card discovered and none named (--card NAME)")
}
}
pub trait Progress {
fn out(&mut self, line: &str);
fn err(&mut self, line: &str);
fn transient(&mut self, line: &str) {
self.err(line);
}
fn clear_transient(&mut self) {}
fn cancelled(&self) -> bool {
false
}
}
pub struct Stdio;
impl Progress for Stdio {
fn out(&mut self, line: &str) {
println!("{line}");
}
fn err(&mut self, line: &str) {
eprintln!("{line}");
}
fn transient(&mut self, line: &str) {
let mut stderr = std::io::stderr();
if stderr.is_terminal() {
let _ = write!(stderr, "\r{line}");
}
}
fn clear_transient(&mut self) {
let mut stderr = std::io::stderr();
if stderr.is_terminal() {
let _ = write!(stderr, "\r");
}
}
}
pub fn check(p: &dyn Progress) -> Result<()> {
anyhow::ensure!(!p.cancelled(), "cancelled");
Ok(())
}