Enum lifxi::http::ColorValidationError
source · pub enum ColorValidationError {
Hue(u16),
SaturationHigh(f32),
SaturationLow(f32),
BrightnessHigh(f32),
BrightnessLow(f32),
KelvinHigh(u16),
KelvinLow(u16),
HsbkEmpty,
RgbStrShort(bool, String),
RgbStrLong(bool, String),
}
Expand description
Represents a (local) color validation error.
Variants
Hue(u16)
The given hue was greater than the maximum hue of 360.
Example
use lifxi::http::prelude::*;
let res = Color::Hue(361).validate();
assert_eq!(res, Err(ColorValidationError::Hue(361)));
SaturationHigh(f32)
The given saturation was greater than 1.0.
Example
use lifxi::http::prelude::*;
let res = Color::Saturation(1.1).validate();
assert_eq!(res, Err(ColorValidationError::SaturationHigh(1.1)));
SaturationLow(f32)
The given saturation was less than 0.0.
Example
use lifxi::http::prelude::*;
let res = Color::Saturation(-0.1).validate();
assert_eq!(res, Err(ColorValidationError::SaturationLow(-0.1)));
BrightnessHigh(f32)
The given brightness was greater than 1.0.
Example
use lifxi::http::prelude::*;
let res = Color::Brightness(1.1).validate();
assert_eq!(res, Err(ColorValidationError::BrightnessHigh(1.1)));
BrightnessLow(f32)
The given brightness was less than 0.0.
Example
use lifxi::http::prelude::*;
let res = Color::Brightness(-0.1).validate();
assert_eq!(res, Err(ColorValidationError::BrightnessLow(-0.1)));
KelvinHigh(u16)
The given temperature was greater than 9000 K.
Example
use lifxi::http::prelude::*;
let res = Color::Kelvin(9001).validate();
assert_eq!(res, Err(ColorValidationError::KelvinHigh(9001)));
KelvinLow(u16)
The given temperature was less than 1500 K.
Example
use lifxi::http::prelude::*;
let res = Color::Kelvin(1499).validate();
assert_eq!(res, Err(ColorValidationError::KelvinLow(1499)));
HsbkEmpty
None of hue, saturation, brightness, or color temperature were specified, so this is an empty color.
Example
use lifxi::http::prelude::*;
let res = Color::Hsbk(None, None, None, None).validate();
assert_eq!(res, Err(ColorValidationError::HsbkEmpty));
RgbStrShort(bool, String)
The given RGB string was too short.
Examples
use lifxi::http::prelude::*;
let res = Color::RgbStr("12345".to_string()).validate();
assert_eq!(res, Err(ColorValidationError::RgbStrShort(false, "12345".to_string())));
let res = Color::RgbStr("#12345".to_string()).validate();
assert_eq!(res, Err(ColorValidationError::RgbStrShort(true, "#12345".to_string())));
RgbStrLong(bool, String)
The given RGB string was too long.
Examples
use lifxi::http::prelude::*;
let res = Color::RgbStr("1234567".to_string()).validate();
assert_eq!(res, Err(ColorValidationError::RgbStrLong(false, "1234567".to_string())));
let res = Color::RgbStr("#1234567".to_string()).validate();
assert_eq!(res, Err(ColorValidationError::RgbStrLong(true, "#1234567".to_string())));
Trait Implementations
sourceimpl Error for Error
impl Error for Error
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl StructuralPartialEq for Error
Auto Trait Implementations
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations
impl<T> AsFail for Twhere
T: Fail,
impl<T> AsFail for Twhere
T: Fail,
fn as_fail(&self) -> &(dyn Fail + 'static)
fn as_fail(&self) -> &(dyn Fail + 'static)
Converts a reference to
Self
into a dynamic trait object of Fail
.sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<E> Fail for Ewhere
E: 'static + Error + Send + Sync,
impl<E> Fail for Ewhere
E: 'static + Error + Send + Sync,
fn cause(&self) -> Option<&(dyn Fail + 'static)>
fn cause(&self) -> Option<&(dyn Fail + 'static)>
Returns a reference to the underlying cause of this failure, if it
is an error that wraps other errors. Read more
fn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
Returns a reference to the
Backtrace
carried by this failure, if it
carries one. Read more