Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SliceWriteError publicly accessible #513

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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