Skip to content

Commit fe13c8f

Browse files
authored
Merge pull request #1132 from spacejam/tyler_0.34
0.34
2 parents 8331943 + 18c405c commit fe13c8f

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Unreleased
1+
# 0.34
2+
3+
## Improvements
4+
5+
* #1132 implemented From<sled::Error> for io::Error to
6+
reduce friction in some situations.
27

38
## Breaking Changes
49

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sled"
3-
version = "0.33.0"
3+
version = "0.34.0"
44
authors = ["Tyler Neely <[email protected]>"]
55
description = "a modern embedded database"
66
license = "MIT/Apache-2.0"

src/result.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,38 @@ impl From<io::Error> for Error {
143143
}
144144
}
145145

146+
impl From<Error> for io::Error {
147+
fn from(error: Error) -> io::Error {
148+
use self::Error::*;
149+
use std::io::ErrorKind;
150+
match error {
151+
Io(ioe) => ioe,
152+
CollectionNotFound(name) =>
153+
io::Error::new(
154+
ErrorKind::NotFound,
155+
format!("collection not found: {:?}", name),
156+
),
157+
Unsupported(why) => io::Error::new(
158+
ErrorKind::InvalidInput,
159+
format!("operation not supported: {:?}", why),
160+
),
161+
ReportableBug(what) => io::Error::new(
162+
ErrorKind::Other,
163+
format!("unexpected bug! please report this bug at <github.rs/spacejam/sled>: {:?}", what),
164+
),
165+
Corruption { .. } => io::Error::new(
166+
ErrorKind::InvalidData,
167+
format!("corruption encountered: {:?}", error),
168+
),
169+
#[cfg(feature = "failpoints")]
170+
FailPoint => io::Error::new(
171+
ErrorKind::Other,
172+
"failpoint"
173+
),
174+
}
175+
}
176+
}
177+
146178
impl StdError for Error {}
147179

148180
impl Display for Error {

0 commit comments

Comments
 (0)