From b2c1c0de1d97ce6f2a756c892b75c5d7e56c01e7 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Thu, 12 Oct 2023 22:03:14 +0100 Subject: [PATCH] Make SliceWriteError publicly accessible --- embedded-io/src/impls/slice_mut.rs | 15 +-------------- embedded-io/src/lib.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/embedded-io/src/impls/slice_mut.rs b/embedded-io/src/impls/slice_mut.rs index 30bb80877..4608ee45b 100644 --- a/embedded-io/src/impls/slice_mut.rs +++ b/embedded-io/src/impls/slice_mut.rs @@ -1,19 +1,6 @@ -use crate::{Error, ErrorKind, ErrorType, Write}; +use crate::{Error, ErrorKind, ErrorType, SliceWriteError, Write}; use core::mem; -// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`. -#[cfg(feature = "defmt-03")] -use defmt_03 as defmt; - -/// Errors that could be returned by `Write` on `&mut [u8]`. -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] -#[non_exhaustive] -pub enum SliceWriteError { - /// The target slice was full and so could not receive any new data. - Full, -} - impl Error for SliceWriteError { fn kind(&self) -> ErrorKind { match self { diff --git a/embedded-io/src/lib.rs b/embedded-io/src/lib.rs index 6358d5286..9f95e636a 100644 --- a/embedded-io/src/lib.rs +++ b/embedded-io/src/lib.rs @@ -259,6 +259,15 @@ impl fmt::Display for ReadExactError { #[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for ReadExactError {} +/// Errors that could be returned by `Write` on `&mut [u8]`. +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] +#[non_exhaustive] +pub enum SliceWriteError { + /// The target slice was full and so could not receive any new data. + Full, +} + /// Error returned by [`Write::write_fmt`] #[derive(Debug, Copy, Clone, Eq, PartialEq)] #[cfg_attr(feature = "defmt-03", derive(defmt::Format))]