pub struct Temperature(/* private fields */);Expand description
Validated temperature value with compile-time type safety.
This newtype wrapper ensures that temperature values are validated at construction time rather than at runtime, catching invalid configurations earlier in development.
§Validation Rules
- Must be between 0.0 and 2.0 (inclusive)
§Example
use open_agent::Temperature;
// Valid temperatures
let temp = Temperature::new(0.7).unwrap();
assert_eq!(temp.value(), 0.7);
let temp = Temperature::new(0.0).unwrap();
assert_eq!(temp.value(), 0.0);
let temp = Temperature::new(2.0).unwrap();
assert_eq!(temp.value(), 2.0);
// Invalid: below range
assert!(Temperature::new(-0.1).is_err());
// Invalid: above range
assert!(Temperature::new(2.1).is_err());Implementations§
Trait Implementations§
Source§impl Clone for Temperature
impl Clone for Temperature
Source§fn clone(&self) -> Temperature
fn clone(&self) -> Temperature
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 Temperature
impl Debug for Temperature
Source§impl Display for Temperature
impl Display for Temperature
Source§impl PartialEq for Temperature
impl PartialEq for Temperature
impl Copy for Temperature
impl StructuralPartialEq for Temperature
Auto Trait Implementations§
impl Freeze for Temperature
impl RefUnwindSafe for Temperature
impl Send for Temperature
impl Sync for Temperature
impl Unpin for Temperature
impl UnwindSafe for Temperature
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.