From 9be154b03cd79c2debe9a089059149ef602c046b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 5 Mar 2026 15:20:45 +0100 Subject: [PATCH] block: Add BlockResult, From Add the public BlockResult type alias and a From impl so that bare I/O errors automatically convert into BlockError with BlockErrorKind::Io via the ? operator. Signed-off-by: Anatol Belski --- block/src/error.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/src/error.rs b/block/src/error.rs index 9ea710c00..4b89bbb21 100644 --- a/block/src/error.rs +++ b/block/src/error.rs @@ -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 for BlockError { + fn from(e: io::Error) -> Self { + Self::new(BlockErrorKind::Io, e) + } +} + +pub type BlockResult = Result;