block: Add BlockResult, From<io::Error>

Add the public BlockResult type alias and a From<io::Error>
impl so that bare I/O errors automatically convert into
BlockError with BlockErrorKind::Io via the ? operator.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-05 15:20:45 +01:00
committed by Rob Bradford
parent 4c29548736
commit 9be154b03c

View File

@@ -18,6 +18,7 @@
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use std::io;
use std::path::PathBuf;
/// Small, stable classification of block errors.
@@ -219,3 +220,12 @@ impl StdError for BlockError {
.map(|e| e.as_ref() as &(dyn StdError + 'static))
}
}
/// Convenience: wrap an `io::Error` as `BlockErrorKind::Io`.
impl From<io::Error> for BlockError {
fn from(e: io::Error) -> Self {
Self::new(BlockErrorKind::Io, e)
}
}
pub type BlockResult<T> = Result<T, BlockError>;