Skip to content

Commit

Permalink
Change Error and ErrorKind to public
Browse files Browse the repository at this point in the history
  • Loading branch information
newAM committed May 13, 2023
1 parent bb2b4e1 commit 6cb008a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.15.1] - 2023-05-13
### Fixed
- Changed the `Error` and `ErrorKind` types from private to public.

## [0.15.0] - 2023-04-22
### Changed
- Updated the alpha release of `embedded-hal` from `1.0.0-alpha.9` to `1.0.0-alpha.10`.
Expand Down Expand Up @@ -135,7 +139,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.0] - 2020-09-12
- Initial release

[Unreleased]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.15.0...HEAD
[Unreleased]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.15.1...HEAD
[0.15.1]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.14.0...v0.15.0
[0.14.0]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.13.0...v0.14.0
[0.13.0]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.12.0...v0.13.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ftdi-embedded-hal"
version = "0.15.0"
version = "0.15.1"
authors = ["Alex Martens <[email protected]>"]
description = "embedded-hal implementation for FTDI USB devices."
keywords = ["ftdi", "usb", "io", "hal"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FTDI device into the [embedded-hal] traits.

```toml
[dependencies.ftdi-embedded-hal]
version = "0.15.0"
version = "0.15.1"
features = ["libftd2xx", "libftd2xx-static"]
```

Expand Down
22 changes: 6 additions & 16 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
use std::fmt;
use std::io;

/// HAL error type combines 3 types of errors:
/// * internal HAL errors
/// * I/O errors
/// * FTDI drivers errors
/// Error type.
#[derive(Debug)]
pub enum Error<E: std::error::Error> {
/// ftdi-embedded-hal implementation specific error.
Hal(ErrorKind),
/// IO error.
Io(io::Error),
/// Backend specific error.
Backend(E),
}

/// Internal HAL errors
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ErrorKind {
InvalidParams,
InvalidClock,
BusBusy,
/// No ACK from the I2C slave
I2cNoAck,
GpioPinBusy,
GpioInvalidPin,
SpiModeNotSupported,
}

impl ErrorKind {
fn as_str(&self) -> &str {
match *self {
ErrorKind::InvalidParams => "Invalid input params",
ErrorKind::BusBusy => "Bus is busy",
ErrorKind::InvalidClock => "Clock is not valid",
ErrorKind::I2cNoAck => "No ACK from slave",
ErrorKind::GpioPinBusy => "GPIO pin is already in use",
ErrorKind::GpioInvalidPin => "No such GPIO pin",
ErrorKind::SpiModeNotSupported => "Mode not supported",
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//!
//! ```toml
//! [dependencies.ftdi-embedded-hal]
//! version = "0.15.0"
//! version = "0.15.1"
//! features = ["libftd2xx", "libftd2xx-static"]
//! ```
//!
Expand Down Expand Up @@ -158,7 +158,7 @@ mod gpio;
mod i2c;
mod spi;

use crate::error::Error;
pub use crate::error::{Error, ErrorKind};
pub use delay::Delay;
pub use gpio::{InputPin, OutputPin};
pub use i2c::I2c;
Expand Down

0 comments on commit 6cb008a

Please sign in to comment.