diff --git a/gpt_disk_io/CHANGELOG.md b/gpt_disk_io/CHANGELOG.md index d7850d3..b48f194 100644 --- a/gpt_disk_io/CHANGELOG.md +++ b/gpt_disk_io/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased * MSRV increased to 1.81. +* The `Error` trait is now unconditionally implemented for all error types. # 0.16.1 diff --git a/gpt_disk_io/README.md b/gpt_disk_io/README.md index 747bc77..eff08d2 100644 --- a/gpt_disk_io/README.md +++ b/gpt_disk_io/README.md @@ -13,8 +13,10 @@ See also the [`gpt_disk_types`] package. ## Features -* `std`: Enables the `StdBlockIo` type, as well as `std::error::Error` - implementations for all of the error types. Off by default. +No features are enabled by default. + +* `alloc`: Enables `Vec` implementation of `BlockIoAdapter`. +* `std`: Enables `std::io` implementations of `BlockIoAdapter`. ## Minimum Supported Rust Version (MSRV) diff --git a/gpt_disk_io/src/block_io/slice_block_io.rs b/gpt_disk_io/src/block_io/slice_block_io.rs index 3870df2..06c5639 100644 --- a/gpt_disk_io/src/block_io/slice_block_io.rs +++ b/gpt_disk_io/src/block_io/slice_block_io.rs @@ -15,11 +15,6 @@ use gpt_disk_types::{BlockSize, Lba}; use alloc::vec::Vec; /// Error type used for `&[u8]` and `&mut [u8]` versions of [`BlockIoAdapter`]. -/// -/// If the `std` feature is enabled, this type implements the [`Error`] -/// trait. -/// -/// [`Error`]: std::error::Error #[allow(clippy::module_name_repetitions)] #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, Ord, PartialOrd)] pub enum SliceBlockIoError { @@ -60,6 +55,8 @@ impl Display for SliceBlockIoError { } } +impl core::error::Error for SliceBlockIoError {} + #[track_caller] fn buffer_byte_range_opt( block_size: BlockSize, diff --git a/gpt_disk_io/src/disk.rs b/gpt_disk_io/src/disk.rs index 26b8459..89fa067 100644 --- a/gpt_disk_io/src/disk.rs +++ b/gpt_disk_io/src/disk.rs @@ -146,6 +146,11 @@ where } } +impl core::error::Error for DiskError where + IoError: Debug + Display +{ +} + /// Read and write GPT disk data. /// /// The disk is accessed via an object implementing the [`BlockIo`] diff --git a/gpt_disk_io/src/lib.rs b/gpt_disk_io/src/lib.rs index d31de85..c6a5526 100644 --- a/gpt_disk_io/src/lib.rs +++ b/gpt_disk_io/src/lib.rs @@ -22,9 +22,7 @@ //! # Features //! //! * `alloc`: Enables [`Vec`] implementation of [`BlockIoAdapter`]. -//! * `std`: Enables [`std::io`] implementations of [`BlockIoAdapter`], -//! as well as `std::error::Error` implementations for all of the -//! error types. Off by default. +//! * `std`: Enables [`std::io`] implementations of [`BlockIoAdapter`]. //! //! # Examples //! @@ -136,8 +134,6 @@ extern crate alloc; mod block_io; mod disk; -#[cfg(feature = "std")] -mod std_support; // Re-export dependencies. pub use gpt_disk_types; diff --git a/gpt_disk_io/src/std_support.rs b/gpt_disk_io/src/std_support.rs deleted file mode 100644 index bcaac5f..0000000 --- a/gpt_disk_io/src/std_support.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use crate::{DiskError, SliceBlockIoError}; -use std::error::Error; -use std::fmt::{Debug, Display}; - -impl Error for DiskError where Custom: Debug + Display {} - -impl Error for SliceBlockIoError {}