pub struct LightValueRange { /* private fields */ }Expand description
A validated light value range advertised by a device driver.
Implementations§
Source§impl LightValueRange
impl LightValueRange
Sourcepub const fn new(
min: u16,
max: u16,
step: u16,
unit: LightValueUnit,
) -> Result<Self, LightValueRangeError>
pub const fn new( min: u16, max: u16, step: u16, unit: LightValueUnit, ) -> Result<Self, LightValueRangeError>
Construct a range after validating its bounds and quantization grid.
The upper bound must lie on the same grid as the lower bound. This keeps driver quantization total: a valid range can never produce a value outside the advertised interval or between device-supported stops.
Sourcepub const fn unit(self) -> LightValueUnit
pub const fn unit(self) -> LightValueUnit
Unit represented by this range.
Sourcepub fn contains(self, value: u16) -> bool
pub fn contains(self, value: u16) -> bool
Whether value is representable without clamping or quantization.
Sourcepub fn quantize(self, value: u16) -> u16
pub fn quantize(self, value: u16) -> u16
Snap value to the nearest supported point inside this range.
Sourcepub fn native_for_percent(self, percent: u8) -> Option<u16>
pub fn native_for_percent(self, percent: u8) -> Option<u16>
Map normalized brightness to the nearest native value in this range.
Sourcepub fn percent_for_native(self, value: u16) -> Option<u8>
pub fn percent_for_native(self, value: u16) -> Option<u8>
Convert a supported native value to normalized brightness.
Trait Implementations§
Source§impl Clone for LightValueRange
impl Clone for LightValueRange
Source§fn clone(&self) -> LightValueRange
fn clone(&self) -> LightValueRange
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for LightValueRange
Source§impl Debug for LightValueRange
impl Debug for LightValueRange
Source§impl<'de> Deserialize<'de> for LightValueRange
impl<'de> Deserialize<'de> for LightValueRange
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for LightValueRange
Source§impl Hash for LightValueRange
impl Hash for LightValueRange
Source§impl PartialEq for LightValueRange
impl PartialEq for LightValueRange
Source§impl Serialize for LightValueRange
impl Serialize for LightValueRange
impl StructuralPartialEq for LightValueRange
Auto Trait Implementations§
impl Freeze for LightValueRange
impl RefUnwindSafe for LightValueRange
impl Send for LightValueRange
impl Sync for LightValueRange
impl Unpin for LightValueRange
impl UnsafeUnpin for LightValueRange
impl UnwindSafe for LightValueRange
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.