Skip to content

Commit

Permalink
Merge pull request #513 from MabezDev/public-slice-write-error
Browse files Browse the repository at this point in the history
Make `SliceWriteError` publicly accessible
  • Loading branch information
Dirbaio authored Oct 20, 2023
2 parents 454f17f + b2c1c0d commit 929dd88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
15 changes: 1 addition & 14 deletions embedded-io/src/impls/slice_mut.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions embedded-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ impl<E: fmt::Debug> fmt::Display for ReadExactError<E> {
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl<E: fmt::Debug> std::error::Error for ReadExactError<E> {}

/// 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))]
Expand Down

0 comments on commit 929dd88

Please sign in to comment.