Skip to content

Commit

Permalink
Implment infallible conversion for ApiError
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Nov 27, 2023
1 parent f501aef commit fdd609f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- `bonsaidb::client::Error` now implements
`From<bonsaidb::client::ApiError<Infallible>>`.

### Fixed

- `bonsaidb::client::Error::Core`'s `Display` no longer just prints "unexpected
Expand Down
10 changes: 10 additions & 0 deletions crates/bonsaidb-client/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use bonsaidb_core::api::Infallible;
use bonsaidb_core::arc_bytes::serde::Bytes;
use bonsaidb_core::networking;
use bonsaidb_core::schema::Name;
Expand Down Expand Up @@ -157,3 +158,12 @@ impl From<ApiError<Self>> for bonsaidb_core::Error {
}
}
}

impl From<ApiError<Infallible>> for Error {
fn from(err: ApiError<Infallible>) -> Self {
match err {
ApiError::Client(err) => err,
ApiError::Api(_) => unreachable!("infallible"),
}
}
}

0 comments on commit fdd609f

Please sign in to comment.