Skip to content

Commit 2eed914

Browse files
committed
return BoxedError from bytes_encode_into_writer for now
1 parent 7431e31 commit 2eed914

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

heed-traits/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ readme = "../README.md"
99
edition = "2021"
1010

1111
[dependencies]
12-
either = "1.13.0"

heed-traits/src/lib.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use std::cmp::{Ord, Ordering};
1313
use std::error::Error as StdError;
1414
use std::io;
1515

16-
use either::Either;
17-
1816
/// A boxed `Send + Sync + 'static` error.
1917
pub type BoxedError = Box<dyn StdError + Send + Sync + 'static>;
2018

@@ -35,20 +33,14 @@ pub trait BytesEncode<'a> {
3533
/// Encode the given item as bytes and write it into the writer. Returns the amount of bytes
3634
/// that were written. This function by default forwards to
3735
/// [`bytes_encode`][BytesEncode::bytes_encode].
38-
///
39-
/// # Errors
40-
///
41-
/// [`Either`] is used to handle the 2 different errors this function can return.
42-
/// [`Either::Left`] is used for errors from [`bytes_encode`][BytesEncode::bytes_encode] and
43-
/// [`Either::Right`] is used for errors from the writer (I/O errors).
4436
fn bytes_encode_into_writer<W: io::Write>(
4537
item: &'a Self::EItem,
4638
writer: &mut W,
47-
) -> Result<usize, Either<Self::Error, io::Error>> {
48-
let bytes = Self::bytes_encode(item).map_err(Either::Left)?;
39+
) -> Result<usize, BoxedError> {
40+
let bytes = Self::bytes_encode(item)?;
4941
let bytes = bytes.as_ref();
5042

51-
writer.write_all(bytes).map_err(Either::Right)?;
43+
writer.write_all(bytes)?;
5244

5345
Ok(bytes.len())
5446
}

0 commit comments

Comments
 (0)