MedianCut,
}
-impl std::string::ToString for QuantMode {
- fn to_string(&self) -> String {
+impl std::fmt::Display for QuantMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- QuantMode::ELBG => "elbg".to_string(),
- QuantMode::Fast => "fast".to_string(),
- QuantMode::MedianCut => "mediancut".to_string(),
+ QuantMode::ELBG => write!(f, "elbg"),
+ QuantMode::Fast => write!(f, "fast"),
+ QuantMode::MedianCut => write!(f, "mediancut"),
}
}
}
Best
}
-impl std::string::ToString for CompressionLevel {
- fn to_string(&self) -> String {
+impl std::fmt::Display for CompressionLevel {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- CompressionLevel::None => "none".to_string(),
- CompressionLevel::Fast => "fast".to_string(),
- CompressionLevel::Best => "best".to_string(),
+ CompressionLevel::None => write!(f, "none"),
+ CompressionLevel::Fast => write!(f, "fast"),
+ CompressionLevel::Best => write!(f, "best"),
}
}
}
}
}
-impl ToString for FrameSkipMode {
- fn to_string(&self) -> String {
+impl std::fmt::Display for FrameSkipMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- FrameSkipMode::None => FRAME_SKIP_OPTION_VAL_NONE.to_string(),
- FrameSkipMode::KeyframesOnly => FRAME_SKIP_OPTION_VAL_KEYFRAME.to_string(),
- FrameSkipMode::IntraOnly => FRAME_SKIP_OPTION_VAL_INTRA.to_string(),
+ FrameSkipMode::None => write!(f, "{FRAME_SKIP_OPTION_VAL_NONE}"),
+ FrameSkipMode::KeyframesOnly => write!(f, "{FRAME_SKIP_OPTION_VAL_KEYFRAME}"),
+ FrameSkipMode::IntraOnly => write!(f, "{FRAME_SKIP_OPTION_VAL_INTRA}"),
}
}
}
}
}
-impl ToString for DeflateMode {
- fn to_string(&self) -> String {
+impl std::fmt::Display for DeflateMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- DeflateMode::NoCompr => DEFLATE_MODE_NONE.to_string(),
- DeflateMode::Fast => DEFLATE_MODE_FAST.to_string(),
- DeflateMode::Better => DEFLATE_MODE_BETTER.to_string(),
- DeflateMode::Best => DEFLATE_MODE_BEST.to_string(),
+ DeflateMode::NoCompr => write!(f, "{DEFLATE_MODE_NONE}"),
+ DeflateMode::Fast => write!(f, "{DEFLATE_MODE_FAST}"),
+ DeflateMode::Better => write!(f, "{DEFLATE_MODE_BETTER}"),
+ DeflateMode::Best => write!(f, "{DEFLATE_MODE_BEST}"),
}
}
}
}
}
-impl ToString for BlockMode {
- fn to_string(&self) -> String {
+impl std::fmt::Display for BlockMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- BlockMode::FourByFour => "4x4".to_string(),
- BlockMode::FourByTwo => "4x2".to_string(),
- BlockMode::TwoByFour => "2x4".to_string(),
- BlockMode::TwoByTwo => "2x2".to_string(),
+ BlockMode::FourByFour => write!(f, "4x4"),
+ BlockMode::FourByTwo => write!(f, "4x2"),
+ BlockMode::TwoByFour => write!(f, "2x4"),
+ BlockMode::TwoByTwo => write!(f, "2x2"),
}
}
}
}
}
-impl ToString for OptionMode {
- fn to_string(&self) -> String {
+impl std::fmt::Display for OptionMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- OptionMode::Off => "off".to_string(),
- OptionMode::On => "on".to_string(),
- OptionMode::Auto => "auto".to_string(),
+ OptionMode::Off => write!(f, "off"),
+ OptionMode::On => write!(f, "on"),
+ OptionMode::Auto => write!(f, "auto"),
}
}
}
Width2XIlace
}
-impl std::string::ToString for DoublingMode {
- fn to_string(&self) -> String {
+impl std::fmt::Display for DoublingMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match *self {
- DoublingMode::None => "none".to_string(),
- DoublingMode::Height2X => "height2x".to_string(),
- DoublingMode::HeightIlace => "height_il".to_string(),
- DoublingMode::Scale2X => "scale2x".to_string(),
- DoublingMode::Width2X => "width2x".to_string(),
- DoublingMode::Width2XIlace => "width2x_il".to_string(),
+ DoublingMode::None => write!(f, "none"),
+ DoublingMode::Height2X => write!(f, "height2x"),
+ DoublingMode::HeightIlace => write!(f, "height_il"),
+ DoublingMode::Scale2X => write!(f, "scale2x"),
+ DoublingMode::Width2X => write!(f, "width2x"),
+ DoublingMode::Width2XIlace => write!(f, "width2x_il"),
}
}
}
}
}
-impl std::string::ToString for BlockMode {
- fn to_string(&self) -> String { BLOCK_MODE_NAMES[usize::from(*self)].to_string() }
+impl std::fmt::Display for BlockMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
+ write!(f, "{}", BLOCK_MODE_NAMES[usize::from(*self)])
+ }
}
impl BlockMode {