Struct CurrentReadingBuilder

Source
pub struct CurrentReadingBuilder { /* private fields */ }
Expand description

Builder for constructing CurrentReading with device-specific fields.

Use build for unchecked construction, or try_build for validation of field values.

Implementations§

Source§

impl CurrentReadingBuilder

Source

pub fn co2(self, co2: u16) -> Self

Set CO2 concentration (Aranet4).

Source

pub fn temperature(self, temp: f32) -> Self

Set temperature.

Source

pub fn pressure(self, pressure: f32) -> Self

Set pressure.

Source

pub fn humidity(self, humidity: u8) -> Self

Set humidity (0-100).

Source

pub fn battery(self, battery: u8) -> Self

Set battery level (0-100).

Source

pub fn status(self, status: Status) -> Self

Set status.

Source

pub fn interval(self, interval: u16) -> Self

Set measurement interval.

Source

pub fn age(self, age: u16) -> Self

Set reading age.

Source

pub fn captured_at(self, timestamp: OffsetDateTime) -> Self

Set the captured timestamp.

Source

pub fn radon(self, radon: u32) -> Self

Set radon concentration (AranetRn+).

Source

pub fn radiation_rate(self, rate: f32) -> Self

Set radiation dose rate (Aranet Radiation).

Source

pub fn radiation_total(self, total: f64) -> Self

Set total radiation dose (Aranet Radiation).

Source

pub fn radon_avg_24h(self, avg: u32) -> Self

Set 24-hour average radon concentration (AranetRn+).

Source

pub fn radon_avg_7d(self, avg: u32) -> Self

Set 7-day average radon concentration (AranetRn+).

Source

pub fn radon_avg_30d(self, avg: u32) -> Self

Set 30-day average radon concentration (AranetRn+).

Source

pub fn build(self) -> CurrentReading

Build the CurrentReading without validation.

Source

pub fn try_build(self) -> Result<CurrentReading, ParseError>

Build the CurrentReading with validation.

Validates:

  • humidity is 0-100
  • battery is 0-100
  • temperature is within reasonable range (-40 to 100°C)
  • pressure is within reasonable range (800-1200 hPa) or 0
§Errors

Returns ParseError::InvalidValue if any field has an invalid value.

Trait Implementations§

Source§

impl Debug for CurrentReadingBuilder

Source§

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

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

impl Default for CurrentReadingBuilder

Source§

fn default() -> CurrentReadingBuilder

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.