ansi_color_codec/codec.rs
1pub use crate::decoder::Decoder;
2pub use crate::encoder::Encoder;
3
4/// Gives the ability to en- / decode bytes to / from ANSI background colors.
5pub trait Codec: Encoder + Decoder {
6 /// Encode bytes into ANSI colors.
7 fn encode(self) -> <Self as Encoder>::Encoder;
8
9 /// Decode ANSI color codes into bytes.
10 fn decode(self) -> <Self as Decoder>::Decoder;
11}
12
13impl<T> Codec for T
14where
15 T: Encoder + Decoder,
16{
17 fn encode(self) -> <Self as Encoder>::Encoder {
18 <Self as Encoder>::encode(self)
19 }
20
21 fn decode(self) -> <Self as Decoder>::Decoder {
22 <Self as Decoder>::decode(self)
23 }
24}