1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Error types for URM37 sensor operations.
//!
//! Errors can arise from two sources:
//! 1. **Transport errors** (wrapped from the underlying HAL)
//! 2. **Protocol errors** (invalid checksums, timeouts, out-of-range readings)
/// All possible errors returned by the URM37 driver.
///
/// This is a generic error type parameterized over the underlying transport error `E`.
/// This allows the driver to be agnostic to the specific UART or communication layer
/// without sacrificing error type information.
///
/// # Example
/// ```ignore
/// use urm37::Error;
///
/// match sensor.read_distance() {
/// Ok(cm) => println!("Distance: {} cm", cm),
/// Err(Error::Bus(e)) => eprintln!("UART error: {:?}", e),
/// Err(Error::Timeout) => eprintln!("No response from sensor"),
/// Err(Error::InvalidReading) => eprintln!("Sensor out of range"),
/// _ => eprintln!("Other error"),
/// }
/// ```