pub struct IoTReading {
pub id: Uuid,
pub building_id: Uuid,
pub device_type: DeviceType,
pub metric_type: MetricType,
pub value: f64,
pub unit: String,
pub timestamp: DateTime<Utc>,
pub source: String,
pub metadata: Option<Value>,
pub created_at: DateTime<Utc>,
}Expand description
IoT sensor reading entity Stores time-series data from various IoT devices (Linky smart meters, temperature sensors, etc.)
Fields§
§id: Uuid§building_id: Uuid§device_type: DeviceType§metric_type: MetricType§value: f64§unit: String§timestamp: DateTime<Utc>§source: String§metadata: Option<Value>§created_at: DateTime<Utc>Implementations§
Source§impl IoTReading
impl IoTReading
Sourcepub fn new(
building_id: Uuid,
device_type: DeviceType,
metric_type: MetricType,
value: f64,
unit: String,
timestamp: DateTime<Utc>,
source: String,
) -> Result<Self, String>
pub fn new( building_id: Uuid, device_type: DeviceType, metric_type: MetricType, value: f64, unit: String, timestamp: DateTime<Utc>, source: String, ) -> Result<Self, String>
Create a new IoT reading with validation
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Set metadata (optional context)
Sourcepub fn is_anomalous(
&self,
average_value: f64,
threshold_percentage: f64,
) -> bool
pub fn is_anomalous( &self, average_value: f64, threshold_percentage: f64, ) -> bool
Check if reading is anomalous compared to average Returns true if value exceeds average by more than threshold percentage
Sourcepub fn normalized_value(&self) -> f64
pub fn normalized_value(&self) -> f64
Convert value to standard unit (kWh for electricity, m3 for water/gas, °C for temperature)
Trait Implementations§
Source§impl Clone for IoTReading
impl Clone for IoTReading
Source§fn clone(&self) -> IoTReading
fn clone(&self) -> IoTReading
Returns a duplicate of the value. Read more
1.0.0 · 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 IoTReading
impl Debug for IoTReading
Source§impl<'de> Deserialize<'de> for IoTReading
impl<'de> Deserialize<'de> for IoTReading
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
Source§impl From<IoTReading> for IoTReadingResponseDto
impl From<IoTReading> for IoTReadingResponseDto
Source§fn from(reading: IoTReading) -> Self
fn from(reading: IoTReading) -> Self
Converts to this type from the input type.
Source§impl PartialEq for IoTReading
impl PartialEq for IoTReading
Source§impl Serialize for IoTReading
impl Serialize for IoTReading
impl StructuralPartialEq for IoTReading
Auto Trait Implementations§
impl Freeze for IoTReading
impl RefUnwindSafe for IoTReading
impl Send for IoTReading
impl Sync for IoTReading
impl Unpin for IoTReading
impl UnwindSafe for IoTReading
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.