Skip to main content

StoredReading

Struct StoredReading 

Source
pub struct StoredReading {
Show 15 fields pub id: i64, pub device_id: String, pub captured_at: OffsetDateTime, pub co2: u16, pub temperature: f32, pub pressure: f32, pub humidity: u8, pub battery: u8, pub status: Status, pub radon: Option<u32>, pub radiation_rate: Option<f32>, pub radiation_total: Option<f64>, pub radon_avg_24h: Option<u32>, pub radon_avg_7d: Option<u32>, pub radon_avg_30d: Option<u32>,
}
Expand description

A current sensor reading stored in the database.

This represents a point-in-time reading captured from a device, typically via BLE connection. Unlike StoredHistoryRecord, these are readings captured by your application, not downloaded from the device’s internal memory.

§Supported Sensor Types

  • Aranet4: CO2, temperature, pressure, humidity
  • Aranet2: Temperature, humidity
  • AranetRn+ (Radon): Radon level, temperature, humidity, pressure
  • AranetRad (Radiation): Radiation rate/total, temperature, humidity

Fields for unsupported sensors (e.g., radon for Aranet4) will be None.

Fields§

§id: i64

Database row ID.

§device_id: String

Device identifier.

§captured_at: OffsetDateTime

When this reading was captured.

§co2: u16

CO2 concentration in ppm.

§temperature: f32

Temperature in Celsius.

§pressure: f32

Pressure in hPa.

§humidity: u8

Humidity percentage.

§battery: u8

Battery percentage.

§status: Status

Status indicator.

§radon: Option<u32>

Radon level (Bq/m3) for radon devices.

§radiation_rate: Option<f32>

Radiation rate in uSv/h for radiation devices.

§radiation_total: Option<f64>

Total radiation dose in mSv for radiation devices.

§radon_avg_24h: Option<u32>

24-hour average radon concentration in Bq/m³ (radon devices only).

§radon_avg_7d: Option<u32>

7-day average radon concentration in Bq/m³ (radon devices only).

§radon_avg_30d: Option<u32>

30-day average radon concentration in Bq/m³ (radon devices only).

Implementations§

Source§

impl StoredReading

Source

pub fn from_reading_with_id( device_id: &str, reading: &CurrentReading, id: i64, ) -> Self

Create a StoredReading from an aranet_types::CurrentReading with an explicit row ID.

Source

pub fn from_reading(device_id: &str, reading: &CurrentReading) -> Self

Create a StoredReading from an aranet_types::CurrentReading.

The database id is set to 0 and will be assigned by SQLite on insert. If captured_at is None in the source reading, the current time is used.

§Arguments
  • device_id - The device identifier this reading came from
  • reading - The source reading from aranet-types
Source

pub fn to_reading(&self) -> CurrentReading

Convert back to an aranet_types::CurrentReading.

Note: Some fields are not preserved in storage:

  • interval and age are set to 0

Use this when you need to pass stored data to functions expecting CurrentReading.

Trait Implementations§

Source§

impl Clone for StoredReading

Source§

fn clone(&self) -> StoredReading

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StoredReading

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for StoredReading

Source§

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 Serialize for StoredReading

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,