pub struct SensorReading {
pub sensor_id: String,
pub kind: SensorKind,
pub value: f64,
pub extra: Vec<f64>,
pub timestamp: f64,
pub confidence: f64,
}Expand description
A single sensor reading with timestamp.
Fields§
§sensor_id: StringSensor identifier (e.g., “cpu_temp”, “left_motor_encoder”).
kind: SensorKindType of sensor.
value: f64Raw value (unit depends on sensor type).
extra: Vec<f64>Optional secondary values (e.g., 3-axis IMU: x, y, z).
timestamp: f64Timestamp of reading.
confidence: f64Confidence (0.0–1.0), 1.0 = fully trusted.
Implementations§
Source§impl SensorReading
impl SensorReading
Sourcepub fn new(sensor_id: impl Into<String>, kind: SensorKind, value: f64) -> Self
pub fn new(sensor_id: impl Into<String>, kind: SensorKind, value: f64) -> Self
Create a new sensor reading with current timestamp and full confidence.
Sourcepub fn with_extra(self, extra: Vec<f64>) -> Self
pub fn with_extra(self, extra: Vec<f64>) -> Self
Add extra values (e.g., 3-axis data).
Sourcepub const fn with_confidence(self, confidence: f64) -> Self
pub const fn with_confidence(self, confidence: f64) -> Self
Set confidence.
Trait Implementations§
Source§impl Clone for SensorReading
impl Clone for SensorReading
Source§fn clone(&self) -> SensorReading
fn clone(&self) -> SensorReading
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SensorReading
impl Debug for SensorReading
Source§impl<'de> Deserialize<'de> for SensorReading
impl<'de> Deserialize<'de> for SensorReading
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SensorReading
impl RefUnwindSafe for SensorReading
impl Send for SensorReading
impl Sync for SensorReading
impl Unpin for SensorReading
impl UnsafeUnpin for SensorReading
impl UnwindSafe for SensorReading
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more