From fc79d08d7ddffa2a5ca743327e89e0e689f02b53 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 14 Mar 2026 01:07:31 +0100 Subject: [PATCH] block: qcow: Remove From for BlockError All public qcow functions now return BlockResult with explicit error classification at every site. The temporary From impl introduced in the first commit of this series is no longer needed and is removed. Internal functions in header.rs and the rebuild_refcounts helpers stay on qcow::Result. Classification happens at the call site boundary where qcow::Result meets BlockResult. Signed-off-by: Anatol Belski --- block/src/error.rs | 52 ---------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/block/src/error.rs b/block/src/error.rs index b235b17e4..645057005 100644 --- a/block/src/error.rs +++ b/block/src/error.rs @@ -242,56 +242,4 @@ impl From for BlockError { } } -/// Temporary scaffolding: classify a `qcow::Error` into the appropriate -/// `BlockErrorKind`. -/// -/// This impl exists only to allow an incremental migration of the qcow -/// parse/construct chain from `qcow::Result` to `BlockResult`. Each -/// subsequent commit replaces bare `?` sites with explicit -/// `BlockError::new(kind, e)` calls. Once every site is migrated this -/// impl will be removed. -impl From for BlockError { - fn from(e: crate::qcow::Error) -> Self { - use crate::qcow::Error as E; - let kind = match &e { - // Structural / format violations - E::InvalidMagic - | E::BackingFileTooLong(_) - | E::InvalidBackingFileName(_) - | E::InvalidClusterSize - | E::InvalidL1TableSize(_) - | E::InvalidL1TableOffset - | E::InvalidOffset(_) - | E::InvalidRefcountTableOffset - | E::InvalidRefcountTableSize(_) - | E::FileTooBig(_) - | E::NoRefcountClusters - | E::RefcountTableOffEnd - | E::RefcountTableTooLarge - | E::TooManyL1Entries(_) - | E::TooManyRefcounts(_) - | E::SizeTooSmallForNumberOfClusters => BlockErrorKind::InvalidFormat, - - // Unsupported features / versions - E::UnsupportedVersion(_) - | E::UnsupportedFeature(_) - | E::UnsupportedCompressionType - | E::UnsupportedBackingFileFormat(_) - | E::UnsupportedRefcountOrder - | E::BackingFilesDisabled - | E::ShrinkNotSupported => BlockErrorKind::UnsupportedFeature, - - // Corrupt image - E::CorruptImage => BlockErrorKind::CorruptImage, - - // Nesting depth overflow - E::MaxNestingDepthExceeded => BlockErrorKind::Overflow, - - // Everything else is I/O - _ => BlockErrorKind::Io, - }; - Self::new(kind, e) - } -} - pub type BlockResult = Result;