History

[clone] Don't expose hex-error in public interfaces anymore

That's usually a chose unless we also re-export these crates. And that we just avoid for now as I have a feeling we can gain some speed by leveraging the lower-case garantuee offered by git. And even if not, we can be less abstract than what 'hex' does.

Sebastian Thiel committed 6 years ago

Commit 92dab301 parent 4bc78422 files · +17 −7Browse files

Showing the changes to git-object/src (1 of 2 files). Show all

Unified · Split

git-object/src/owned/id.rs+14−2
@@ -1,7 +1,17 @@
11 use crate::{borrowed, SHA1_SIZE};
22 use bstr::ByteSlice;
3+use quick_error::quick_error;
34 use std::{fmt, io, ops::Deref};
45
6+quick_error! {
7+ #[derive(Debug)]
8+ pub enum Error {
9+ HexDecode(err: String) {
10+ display("Failed to hex hash: {}", err)
11+ }
12+ }
13+}
14+
515 /// An owned SHA1 identifying objects
616 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
717 #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
@@ -30,9 +40,11 @@ impl Id { · 22 unmodified lines
3040
3141 /// Sha1 hash specific methods
3242 impl Id {
33− pub fn from_40_bytes_in_hex(buf: &[u8]) -> Result<Id, hex::FromHexError> {
43+ pub fn from_40_bytes_in_hex(buf: &[u8]) -> Result<Id, Error> {
3444 use hex::FromHex;
35− Ok(Id(<[u8; 20]>::from_hex(buf)?))
45+ Ok(Id(
46+ <[u8; 20]>::from_hex(buf).map_err(|err| Error::HexDecode(err.to_string()))?
47+ ))
3648 }
3749 pub fn sha1(&self) -> &[u8; SHA1_SIZE] {
3850 &self.0