Author: Daniel Noland [daniel@stateless.net]
Committer: Jason White [github@jasonwhite.io] Tue, 13 Sep 2022 05:19:59 +0000
Hash: 1578e720cdecea38f9e59975f659f12f32702c28
Timestamp: Tue, 13 Sep 2022 05:19:59 +0000 (2 years ago)

+7 -24 +/-3 browse
Bump hex to 0.4
Bump hex to 0.4

This upgrade required a minor refactor but the code does seem cleaner to me now.
1diff --git a/Cargo.lock b/Cargo.lock
2index 196ec97..a93ab89 100644
3--- a/Cargo.lock
4+++ b/Cargo.lock
5 @@ -582,12 +582,6 @@ dependencies = [
6
7 [[package]]
8 name = "hex"
9- version = "0.3.2"
10- source = "registry+https://github.com/rust-lang/crates.io-index"
11- checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
12-
13- [[package]]
14- name = "hex"
15 version = "0.4.3"
16 source = "registry+https://github.com/rust-lang/crates.io-index"
17 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
18 @@ -1155,7 +1149,7 @@ dependencies = [
19 "env_logger 0.9.0",
20 "futures",
21 "generic-array",
22- "hex 0.3.2",
23+ "hex",
24 "http",
25 "human-size",
26 "humansize",
27 @@ -1248,7 +1242,7 @@ dependencies = [
28 "chrono",
29 "digest 0.9.0",
30 "futures",
31- "hex 0.4.3",
32+ "hex",
33 "hmac",
34 "http",
35 "hyper",
36 diff --git a/Cargo.toml b/Cargo.toml
37index 7f661ac..0f4a2dc 100644
38--- a/Cargo.toml
39+++ b/Cargo.toml
40 @@ -24,7 +24,7 @@ chacha = "0.3"
41 derive_more = "0.99"
42 futures = "0.3"
43 generic-array = "0.14"
44- hex = "0.3"
45+ hex = "0.4"
46 http = "0.2"
47 human-size = "0.4"
48 humansize = "1"
49 diff --git a/src/sha256.rs b/src/sha256.rs
50index f46de9a..322242f 100644
51--- a/src/sha256.rs
52+++ b/src/sha256.rs
53 @@ -28,7 +28,7 @@ use futures::{ready, Stream};
54 use hex::{FromHex, FromHexError, ToHex};
55 use serde::{
56 de::{self, Deserializer, Visitor},
57- ser::{self, Serializer},
58+ ser::Serializer,
59 Deserialize, Serialize,
60 };
61
62 @@ -119,15 +119,9 @@ impl FromStr for Sha256 {
63 }
64 }
65
66- impl fmt::UpperHex for Sha256 {
67- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
68- self.write_hex_upper(f)
69- }
70- }
71-
72 impl fmt::LowerHex for Sha256 {
73 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
74- self.write_hex(f)
75+ f.write_str(hex::encode(self).as_str())
76 }
77 }
78
79 @@ -159,13 +153,8 @@ impl Serialize for Sha256 {
80 S: Serializer,
81 {
82 if serializer.is_human_readable() {
83- // Serialize as a hex string.
84- let mut hex = String::new();
85- self.0
86- .as_slice()
87- .write_hex(&mut hex)
88- .map_err(ser::Error::custom)?;
89- serializer.serialize_str(&hex)
90+ let hex: String = self.encode_hex();
91+ serializer.serialize_str(hex.as_str())
92 } else {
93 // Serialize as a byte array with known length.
94 serializer.serialize_bytes(self.0.as_ref())