Use anyhow

This commit is contained in:
clerie 2024-12-23 17:15:38 +01:00
parent b3b7a4ea27
commit b4089a2b7e

View File

@ -1,4 +1,5 @@
use anyhow::{ use anyhow::{
bail,
Context, Context,
Result, Result,
}; };
@ -10,7 +11,7 @@ use crate::improv::{
ImprovDataToPacket, ImprovDataToPacket,
}; };
pub fn find_begin_of_improv_packet(buffer: &Vec<u8>) -> Result<usize, String> { pub fn find_begin_of_improv_packet(buffer: &Vec<u8>) -> Result<usize> {
let mut improv_header_char: usize = 0; let mut improv_header_char: usize = 0;
for (i, b) in buffer.iter().enumerate() { for (i, b) in buffer.iter().enumerate() {
@ -29,7 +30,7 @@ pub fn find_begin_of_improv_packet(buffer: &Vec<u8>) -> Result<usize, String> {
} }
} }
return Err(String::from("Improv header not found")); bail!("Improv header not found");
} }
pub struct SerialInterface { pub struct SerialInterface {