examples: error message on connection failure

This commit is contained in:
Vinzenz Schroeter 2024-06-23 10:41:46 +02:00
parent 7200cb3247
commit e1f009ee6f
6 changed files with 16 additions and 9 deletions

View file

@ -22,9 +22,11 @@ fn main() {
cli.text.push("Hello, CCCB!".to_string());
}
let connection = Connection::open(&cli.destination).unwrap();
let connection = Connection::open(&cli.destination)
.expect("could not connect to display");
if cli.clear {
connection.send(Command::Clear).unwrap();
connection.send(Command::Clear).expect("sending clear failed");
}
let max_width = cli.text.iter().map(|t| t.len()).max().unwrap();
@ -41,5 +43,5 @@ fn main() {
connection
.send(Command::Cp437Data(Origin(0, 0), chars))
.unwrap();
.expect("sending text failed");
}

View file

@ -13,7 +13,8 @@ struct Cli {
fn main() {
let cli = Cli::parse();
let connection = Connection::open(cli.destination).unwrap();
let connection = Connection::open(cli.destination)
.expect("could not connect to display");
let mut pixels = PixelGrid::max_sized();
pixels.fill(true);

View file

@ -18,7 +18,8 @@ struct Cli {
fn main() {
let cli = Cli::parse();
let connection = Connection::open(&cli.destination).unwrap();
let connection = Connection::open(&cli.destination)
.expect("could not connect to display");
let mut field = make_random_field(cli.probability);
loop {

View file

@ -13,7 +13,8 @@ struct Cli {
}
fn main() {
let connection = Connection::open(Cli::parse().destination).unwrap();
let connection = Connection::open(Cli::parse().destination)
.expect("could not connect to display");
let mut pixels = PixelGrid::max_sized();
for x_offset in 0..usize::MAX {

View file

@ -22,7 +22,8 @@ struct Cli {
fn main() {
let cli = Cli::parse();
let connection = Connection::open(cli.destination).unwrap();
let connection = Connection::open(cli.destination)
.expect("could not connect to display");
let wait_duration = Duration::from_millis(cli.wait_ms);
// put all pixels in on state

View file

@ -22,7 +22,8 @@ fn main() {
Duration::from_millis(cli.time / PIXEL_WIDTH as u64),
);
let connection = Connection::open(cli.destination).unwrap();
let connection = Connection::open(cli.destination)
.expect("could not connect to display");
let mut enabled_pixels = PixelGrid::new(PIXEL_WIDTH, PIXEL_HEIGHT);
enabled_pixels.fill(true);
@ -38,7 +39,7 @@ fn main() {
connection
.send(Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma))
.unwrap();
.expect("could not send command to display");
thread::sleep(sleep_duration);
}
}