Struct tcn75a::Temperature[][src]

pub struct Temperature(_);
Expand description

A struct representing a temperature reading from the TCN75A.

Internals

Temperature is a newtype over the FixedI16::<U8> (I8F8) type provided by the fixed crate.

Invariants

The user cannot create this type; it mainly exists to provide a runtime guarantee that the contained data was successfully read from the TCN75A.

Examples

To compare, add, subtract, compare, etc temperature measurements from a TCN75A, you should convert a Temperature to a I8F8 type. Temperature implements Copy, so a Temperature can be used simultaneously with its contained I8F8.

use fixed::types::I8F8;
use fixed_macro::fixed;

let temp0: I8F8 = tcn.temperature()?.into();
// ... Assume some time has passed.
let baseline: I8F8 = fixed!(25.0 : I8F8);

if temp0 < baseline {
    println!("Temperature is less than 25.0C.");
} else if temp0 > baseline {
    println!("Temperature is greater than 25.0C.");
} else {
    println!("Temperature is 25.0C.");
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Casts the value.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Casts the value.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Casts the value.

Should always be Self

Casts the value.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Casts the value.

Casts the value.