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
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for Temperature
impl Send for Temperature
impl Sync for Temperature
impl Unpin for Temperature
impl UnwindSafe for Temperature
Blanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Performs the conversion.
Performs the conversion.
Casts the value.
type Output = T
type Output = T
Should always be Self
Casts the value.
Casts the value.
Casts the value.