]> git.nihav.org Git - nihav.git/commitdiff
replace ToString with Display implementation
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 3 Feb 2026 17:56:53 +0000 (18:56 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 3 Feb 2026 17:56:53 +0000 (18:56 +0100)
nihav-commonfmt/src/codecs/cinepakenc.rs
nihav-commonfmt/src/codecs/gifenc.rs
nihav-core/src/codecs/mod.rs
nihav-core/src/compr/deflate.rs
nihav-duck/src/codecs/truemotion1enc.rs
nihav-rad/src/codecs/binkvidenc.rs

index 8d78fb311c2e70e6521ff689c423e857a1b48930..f2b90499d3e69e36d60e8154175a294a0f21b1d0 100644 (file)
@@ -218,12 +218,12 @@ enum QuantMode {
     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"),
         }
     }
 }
index 4a1e2b710f4a245cb7dc12c788f24dcb801584e2..c67fb6b6262db2f31379285707129d59745306b9 100644 (file)
@@ -20,12 +20,12 @@ enum CompressionLevel {
     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"),
         }
     }
 }
index 5a2b94530e809510d53363f8935d79d85473b7e2..20099011ab73a05eaf05d7be414dc34bf85ed0cd 100644 (file)
@@ -227,12 +227,12 @@ impl FromStr for FrameSkipMode {
     }
 }
 
-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}"),
         }
     }
 }
index 72c583b48d525554477065ddff136100d462ee21..eabfa63dccc506986367ab51a2449d31d13c3fc7 100644 (file)
@@ -1955,13 +1955,13 @@ impl std::str::FromStr for DeflateMode {
     }
 }
 
-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}"),
         }
     }
 }
index 2ebd56709676d067e73fd4841c98157dd23acc15..bdf710fde3fdb0ed76a224980d93a00355db9544 100644 (file)
@@ -25,13 +25,13 @@ impl FromStr for BlockMode {
     }
 }
 
-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"),
         }
     }
 }
@@ -56,12 +56,12 @@ impl FromStr for OptionMode {
     }
 }
 
-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"),
         }
     }
 }
index b3cbbf1bdf8ab7594306bf9cf0ec1d43f80adf2a..c47aba6524d46d1b24521ee90e7dd05407bba239 100644 (file)
@@ -26,15 +26,15 @@ enum DoublingMode {
     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"),
         }
     }
 }
@@ -93,8 +93,10 @@ impl std::str::FromStr for BlockMode {
     }
 }
 
-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 {