1use core::fmt::Result;
2
3use crate::{CodeWriter, ColorTarget};
4pub use basic::*;
5pub use color::*;
6pub use indexed::*;
7pub use rgb::*;
8pub use simple::*;
9
10mod basic;
11mod color;
12mod indexed;
13mod rgb;
14mod simple;
15
16pub(crate) trait WriteColorCodes {
17 fn write_color_codes(self, target: ColorTarget, writer: &mut CodeWriter) -> Result;
18}
19
20macro_rules! impl_reflexive_partial_eq {
21 ($stricter:ident :: $method:ident () -> $general:ty) => {
22 impl PartialEq<$stricter> for $general {
23 fn eq(&self, other: &$stricter) -> bool {
24 *self == other.$method()
25 }
26 }
27
28 impl PartialEq<$general> for $stricter {
29 fn eq(&self, other: &$general) -> bool {
30 self.$method() == *other
31 }
32 }
33 };
34}
35
36impl_reflexive_partial_eq!(BasicColor::to_color() -> Color);
37impl_reflexive_partial_eq!(SimpleColor::to_color() -> Color);
38impl_reflexive_partial_eq!(IndexedColor::to_color() -> Color);
39impl_reflexive_partial_eq!(RGBColor::to_color() -> Color);
40impl_reflexive_partial_eq!(BasicColor::to_simple_color() -> SimpleColor);