Enum lifxi::http::ColorParseError
source · pub enum ColorParseError {
Show 21 variants
NoHue,
NonNumericHue(ParseIntError),
NoSaturation,
NonNumericSaturation(ParseFloatError),
NoBrightness,
NonNumericBrightness(ParseFloatError),
NoKelvin,
NonNumericKelvin(ParseIntError),
WeirdHsbkComponent(Color),
MultipleHues,
MultipleSaturations,
MultipleBrightnesses,
MultipleKelvins,
NoRed,
NonNumericRed(ParseIntError),
NoGreen,
NonNumericGreen(ParseIntError),
NoBlue,
NonNumericBlue(ParseIntError),
ShortString,
LongString,
}
Expand description
Represents an error encountered while deserializing a color.
Variants
NoHue
No hue was given.
Example
use lifxi::http::prelude::*;
let color = "hue:".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoHue));
NonNumericHue(ParseIntError)
The hue could not be parsed as an integer.
Example
use lifxi::http::prelude::*;
let color = "hue:j".parse::<Color>();
assert!(color.is_err());
NoSaturation
No saturation was given.
Example
use lifxi::http::prelude::*;
let color = "saturation:".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoSaturation));
NonNumericSaturation(ParseFloatError)
The saturation could not be parsed as a float.
Example
use lifxi::http::prelude::*;
let color = "saturation:j".parse::<Color>();
assert!(color.is_err());
NoBrightness
No brightness was given.
Example
use lifxi::http::prelude::*;
let color = "brightness:".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoBrightness));
NonNumericBrightness(ParseFloatError)
The brightness could not be parsed as a float.
Example
use lifxi::http::prelude::*;
let color = "brightness:j".parse::<Color>();
assert!(color.is_err());
NoKelvin
No color temperature was given.
Example
use lifxi::http::prelude::*;
let color = "kelvin:".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoKelvin));
NonNumericKelvin(ParseIntError)
The color temperature could not be parsed as an integer.
Example
use lifxi::http::prelude::*;
let color = "kelvin:j".parse::<Color>();
assert!(color.is_err());
WeirdHsbkComponent(Color)
When parsing our way through what looked like an HSBK color, we found another color.
Example
use lifxi::http::prelude::*;
let color = "hue:100 rgb:0,0,0".parse::<Color>();
assert!(color.is_err());
MultipleHues
Multiple hues were specified.
use lifxi::http::prelude::*;
let color = "hue:100 hue:100".parse::<Color>();
assert_eq!(color, Err(ColorParseError::MultipleHues));
MultipleSaturations
Multiple hues were specified.
use lifxi::http::prelude::*;
let color = "saturation:100 saturation:100".parse::<Color>();
assert_eq!(color, Err(ColorParseError::MultipleSaturations));
MultipleBrightnesses
Multiple hues were specified.
use lifxi::http::prelude::*;
let color = "brightness:0.4 brightness:0.4".parse::<Color>();
assert_eq!(color, Err(ColorParseError::MultipleBrightnesses));
MultipleKelvins
Multiple hues were specified.
use lifxi::http::prelude::*;
let color = "kelvin:2000 kelvin:2000".parse::<Color>();
assert_eq!(color, Err(ColorParseError::MultipleKelvins));
NoRed
No red component was given.
Example
use lifxi::http::prelude::*;
let color = "rgb:".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoRed));
NonNumericRed(ParseIntError)
The red component could not be parsed as an integer.
Example
use lifxi::http::prelude::*;
let color = "rgb:j".parse::<Color>();
assert!(color.is_err());
NoGreen
No green component was given.
Example
use lifxi::http::prelude::*;
let color = "rgb:0,".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoGreen));
NonNumericGreen(ParseIntError)
The green component could not be parsed as an integer.
Example
use lifxi::http::prelude::*;
let color = "rgb:0,j".parse::<Color>();
assert!(color.is_err());
NoBlue
No blue component was given.
Example
use lifxi::http::prelude::*;
let color = "rgb:0,1,".parse::<Color>();
assert_eq!(color, Err(ColorParseError::NoBlue));
NonNumericBlue(ParseIntError)
The blue component could not be parsed as an integer.
Example
use lifxi::http::prelude::*;
let color = "rgb:0,1,j".parse::<Color>();
assert!(color.is_err());
ShortString
The string is too short to be an RGB string and was not recognized as a keyword.
Example
use lifxi::http::prelude::*;
let color = "foo".parse::<Color>();
assert_eq!(color, Err(ColorParseError::ShortString));
LongString
The string is too long to be an RGB string and was not recognized as a keyword.
Example
use lifxi::http::prelude::*;
let color = "foobarbaz".parse::<Color>();
assert_eq!(color, Err(ColorParseError::LongString));
Trait Implementations
sourceimpl Clone for ColorParseError
impl Clone for ColorParseError
sourcefn clone(&self) -> ColorParseError
fn clone(&self) -> ColorParseError
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more