commit_hash
stringlengths
40
40
author
stringlengths
1
57
date
timestamp[s]date
2010-07-26 04:45:09
2026-04-14 18:21:10
message
stringlengths
8
1.39M
diff
stringlengths
68
51.2k
files_changed
int64
1
136
insertions
int64
0
2.35k
deletions
int64
0
1.9k
257218bc1477a845139f84f816c8775aa14ecd47
Vincent Prouillet
2016-08-23T17:03:33
Remove silly match
diff --git a/src/lib.rs b/src/lib.rs index 9acb8fd..c62a605 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,10 +141,7 @@ pub fn sign(data: &str, secret: &[u8], algorithm: Algorithm) -> String { /// Compares the signature given with a re-computed signature pub fn verify(signature: &str, data: &str, secret: &[u8], a...
1
1
4
3f986f54a8248ad6be31e7048391c15f26feb2e8
Vincent Prouillet
2016-08-23T16:39:18
rust-crypto -> ring
diff --git a/Cargo.toml b/Cargo.toml index 5986eab..b791f25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["jwt", "web", "api", "token", "json"] [dependencies] rustc-serialize = "0.3" clippy = {version = "~0.0.44", optional = true} -rust-crypto = "0.2.35" +ring = "0.2" [features] default ...
2
16
19
1b7ec1057ad0c3e7f17e5686d96efe3f368f1415
Félix Saparelli
2016-04-24T07:18:26
Expose sign() and verify()
diff --git a/src/lib.rs b/src/lib.rs index 1391fdc..8b45170 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,7 +131,7 @@ pub struct TokenData<T: Part> { /// Take the payload of a JWT and sign it using the algorithm given. /// Returns the base64 url safe encoded of the hmac result -fn sign(data: &str, secret: &[u8],...
1
2
2
6d50f5bcd12c2783521dd67fbe201a3eb249dfd6
Warts Werdna
2016-04-02T10:41:35
test if header.alg matches algorithm passed to decode()
diff --git a/src/lib.rs b/src/lib.rs index 63045f3..1391fdc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -274,6 +274,14 @@ mod tests { claims.unwrap(); } + #[test] + #[should_panic(expected = "WrongAlgorithmHeader")] + fn decode_token_wrong_algorithm() { + let token = "eyJhbGciOiJIUzUxMiI...
1
8
0
58b617bbcb02ccd9c0f941d4dc1eb291509024b6
Warts Werdna
2016-04-02T10:40:24
add a test for completely normal decoding
diff --git a/src/lib.rs b/src/lib.rs index 5176c1b..63045f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -251,6 +251,13 @@ mod tests { assert!(token_data.header.kid.is_none()); } + #[test] + fn decode_token() { + let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJiQGIuY29tIiwiY29tc...
1
7
0
60b511a97ad8afabea558b990aab3b88522408e7
Vincent Prouillet
2016-03-23T13:27:46
Print token on claims example
diff --git a/examples/claims.rs b/examples/claims.rs index 0e70c18..6b27c73 100644 --- a/examples/claims.rs +++ b/examples/claims.rs @@ -34,6 +34,8 @@ fn main() { Err(_) => panic!() // in practice you would return the error }; + println!("{:?}", token); + let token_data = match decode::<Claims>(...
1
2
0
412ed9738998356d82750ba4001e17aba8cebc54
Warts Werdna
2016-03-19T10:40:58
custom json encoder omits None when serializing
diff --git a/src/lib.rs b/src/lib.rs index 451c391..6b2701e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,7 @@ extern crate crypto; use rustc_serialize::{json, Encodable, Decodable}; use rustc_serialize::base64::{self, ToBase64, FromBase64}; +use rustc_serialize::json::{ToJson, Json}; use crypto::sha2::{Sh...
1
42
1
c49ccb02a1ae92047938cadcf02cbf85c751ea73
Vincent Prouillet
2016-02-29T10:26:36
Update clippy
diff --git a/Cargo.toml b/Cargo.toml index 3d7e97a..6b00d1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["jwt", "web", "api", "token", "json"] [dependencies] rustc-serialize = "0.3" -clippy = {version = "0.0.35", optional = true} +clippy = {version = "~0.0.44", optional = true} rust-crypt...
1
1
1
438d264fa965bf3a7933c5cab1d65fdb5170c1d4
Jonathan Fok kan
2016-02-28T17:30:39
Implemented std::error::Error for jwt::errors::Error
diff --git a/src/errors.rs b/src/errors.rs index a41007b..1d78005 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,4 +1,4 @@ -use std::string; +use std::{string, fmt, error}; use rustc_serialize::{json, base64}; #[derive(Debug)] @@ -28,3 +28,41 @@ impl_from_error!(json::EncoderError, Error::EncodeJSON); impl_f...
1
39
1
7d1b17e87782856974d5dd9617dc3b3eba7caabd
Vincent Prouillet
2016-01-07T14:01:07
Update description and clippy version
diff --git a/Cargo.toml b/Cargo.toml index 291c6e9..3d7e97a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,14 +4,14 @@ version = "1.0.0" authors = ["Vincent Prouillet <vincent@wearewizards.io>"] license = "MIT" readme = "README.md" -description = "Create and parse JWT." +description = "Create and parse JWT in a stro...
1
2
2
f7e87663e2270f158e27e96225875a6ddaf629f1
Vincent Prouillet
2015-12-20T01:16:52
More examples + fix header struct access
diff --git a/examples/claims.rs b/examples/claims.rs index 25af8d7..a8330fb 100644 --- a/examples/claims.rs +++ b/examples/claims.rs @@ -4,29 +4,44 @@ extern crate rustc_serialize; use jwt::{encode, decode, Header, Algorithm}; use jwt::errors::{Error}; + #[derive(Debug, RustcEncodable, RustcDecodable)] struct Cla...
3
62
9
3930338105346ad6bd8d45ab19fb01d1d5cb8127
Vincent Prouillet
2015-12-20T01:03:20
Move macro out of decode + some docstring changes
diff --git a/src/lib.rs b/src/lib.rs index 34f94ae..1a15b70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,8 +52,8 @@ impl<T> Part for T where T: Encodable + Decodable { } #[derive(Debug, PartialEq, RustcDecodable, RustcEncodable)] -/// A basic JWT header part, the alg is automatically filled for use -/// and the ...
1
16
18
275c95281f6b61431a1688cbd0d1cb93f937ca7a
Vincent Prouillet
2015-12-20T00:41:22
Use bytes for secret on encode as well for symmetry
diff --git a/benches/jwt.rs b/benches/jwt.rs index ad0a2ab..1de9124 100644 --- a/benches/jwt.rs +++ b/benches/jwt.rs @@ -18,7 +18,7 @@ fn bench_encode(b: &mut test::Bencher) { company: "ACME".to_owned() }; - b.iter(|| encode(&claim, "secret", Header::default())); + b.iter(|| encode(&claim, "secret...
2
4
4
1179eb8b557c978081d291b6e42a70e59ec70eba
Vincent Prouillet
2015-12-18T21:07:48
Add all params of header from RFC
diff --git a/benches/jwt.rs b/benches/jwt.rs index d45d193..ad0a2ab 100644 --- a/benches/jwt.rs +++ b/benches/jwt.rs @@ -3,7 +3,7 @@ extern crate test; extern crate jsonwebtoken as jwt; extern crate rustc_serialize; -use jwt::{encode, decode, Algorithm}; +use jwt::{encode, decode, Algorithm, Header}; #[derive(De...
3
62
69
d6d0ce058b1cfa1d6c579539329abc3bb9b6e891
Markus Unterwaditzer
2015-12-13T15:29:12
Allow non-UTF8 keys for decoding too
diff --git a/examples/claims.rs b/examples/claims.rs index 4deb81b..b6bbe39 100644 --- a/examples/claims.rs +++ b/examples/claims.rs @@ -21,7 +21,7 @@ fn main() { Err(_) => panic!() // in practice you would return the error }; - let claims = match decode::<Claims>(&token, key, Algorithm::HS256) { + ...
2
22
6
3dc9295a54e153383c0f598e6a1969e6c947f318
Kevin Butler
2015-11-05T19:34:08
Allow custom encoded types for Part
diff --git a/src/lib.rs b/src/lib.rs index cb7a7a5..ee2a32a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,12 +30,16 @@ pub enum Algorithm { /// A part of the JWT: header and claims specifically /// Allows converting from/to struct with base64 pub trait Part { + type Encoded: AsRef<str>; + fn from_base64<B:...
1
11
5
0f41c3168767bc5062116d936d1d28566e20aa5b
Kevin Butler
2015-11-05T19:29:42
Precompute headers
diff --git a/src/lib.rs b/src/lib.rs index d25eee9..cb7a7a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ use crypto::util::fixed_time_eq; pub mod errors; use errors::Error; -#[derive(Debug, PartialEq, Copy, Clone, RustcDecodable, RustcEncodable)] +#[derive(Debug, PartialEq, Copy, Clone)] /// The algo...
1
27
4
4ebcfca049621094727ab7db33d959f015aa77fc
Kevin Butler
2015-11-05T18:09:39
Rewrite decode
diff --git a/benches/jwt.rs b/benches/jwt.rs index 26f1f97..d45d193 100644 --- a/benches/jwt.rs +++ b/benches/jwt.rs @@ -23,10 +23,6 @@ fn bench_encode(b: &mut test::Bencher) { #[bench] fn bench_decode(b: &mut test::Bencher) { - let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZS...
3
23
20
486c4a87f9603250167e40d70da2845e04a07500
Kevin Butler
2015-11-05T17:45:43
Use constant time comparison for hmacs, see MacResult::code for warning
diff --git a/src/lib.rs b/src/lib.rs index cfa9d4c..c0b221d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ use crypto::sha2::{Sha256, Sha384, Sha512}; use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::digest::Digest; +use crypto::util::fixed_time_eq; pub mod errors; use errors::Error; @@ -81,...
1
2
1
6138bf3dceeff25ac2bbe5c1eba6688d728aed08
Kevin Butler
2015-11-05T17:32:08
Minor test cleanup
diff --git a/src/lib.rs b/src/lib.rs index 15856a3..cfa9d4c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,7 +159,7 @@ mod tests { #[test] fn sign_hs256() { - let result = sign("hello world", "secret".as_bytes(), Algorithm::HS256); + let result = sign("hello world", b"secret", Algorithm::HS2...
1
7
5
09c4d146097a4f0fa50c75f7d545bcab3acc2f33
Kevin Butler
2015-11-05T17:10:55
Weaken parameter requirements for encode
diff --git a/benches/jwt.rs b/benches/jwt.rs index 92f7d2c..26f1f97 100644 --- a/benches/jwt.rs +++ b/benches/jwt.rs @@ -13,14 +13,12 @@ struct Claims { #[bench] fn bench_encode(b: &mut test::Bencher) { - b.iter(|| encode::<Claims>( - Claims { - sub: "b@b.com".to_owned(), - company: ...
3
10
12
b1c10c7085021be791e4b6f84befe2b77e9d3f53
Kevin Butler
2015-11-05T16:22:04
Weaken parameter requirements for Part::from_base64
diff --git a/src/lib.rs b/src/lib.rs index d3e5a2d..8b96bbf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ pub enum Algorithm { /// A part of the JWT: header and claims specifically /// Allows converting from/to struct with base64 pub trait Part { - fn from_base64(encoded: String) -> Result<Self, Erro...
1
6
6
fb229e14257045d8d63c11eadcc7d24f25bccb06
Vincent Prouillet
2015-11-03T16:00:52
Better example
diff --git a/examples/claims.rs b/examples/claims.rs index 28efba5..92a56e0 100644 --- a/examples/claims.rs +++ b/examples/claims.rs @@ -1,11 +1,8 @@ extern crate jsonwebtoken as jwt; extern crate rustc_serialize; -use jwt::{ - Algorithm, - encode, - decode -}; +use jwt::{encode, decode, Algorithm}; +use j...
1
14
7
6ae77c0b068328c47febe4169d6d28c0c66ba101
Vincent Prouillet
2015-11-02T23:12:01
Make Algorithm encodable/decodable rather than using String
diff --git a/src/lib.rs b/src/lib.rs index dc04787..d3e5a2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,24 +18,14 @@ use crypto::digest::Digest; pub mod errors; use errors::Error; -#[derive(Debug, Copy, Clone, RustcDecodable, RustcEncodable)] -/// The algorithms supported for signing, so far only Hmac Sha256 +#...
1
9
19
d29f670989f2e62252c171c7195dc5a6a5d97082
Vincent Prouillet
2015-11-01T22:59:42
Add mini docs
diff --git a/src/errors.rs b/src/errors.rs index 68b6b2b..71e0271 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -2,11 +2,15 @@ use std::string; use rustc_serialize::{json, base64}; #[derive(Debug)] +/// All the errors we can encounter while signing/verifying tokens +/// and a couple of custom one for when the t...
2
22
14
3452ba26d18f401ca8457d014befd7a760cfaa9a
Vincent Prouillet
2015-11-01T22:31:46
Add basic working code
diff --git a/src/errors.rs b/src/errors.rs index 940a0db..68b6b2b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -7,6 +7,8 @@ pub enum Error { DecodeBase64(base64::FromBase64Error), DecodeJSON(json::DecoderError), Utf8(string::FromUtf8Error), + InvalidToken, + InvalidSignature } macro_rules!...
2
95
24
2253cdec4f0978596856d38513cc5ab14c8fcd86
Vincent Prouillet
2015-11-01T19:32:43
wip crypto
diff --git a/Cargo.toml b/Cargo.toml index 91b098f..32f40b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ keywords = ["jwt", "web", "api", "token"] [dependencies] rustc-serialize = "0.3" clippy = {version = "0.0.22", optional = true} +rust-crypto = "0.2.34" [features] default = [] diff --git a/src/c...
4
109
163
8d5d7382831c806fef06fe46602213ec587f07e9
KodrAus
2025-11-22T21:16:18
use serde_core instead of serde
diff --git a/Cargo.toml b/Cargo.toml index 3d2c37f..ff93fc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,14 @@ categories = ["encoding", "no-std"] [features] # Support the standard library -std = ["serde/std"] +std = ["serde_core/std"] -[dependencies.serde] -version = "1.0.104" +[dependencies.serde_core...
2
13
10
202470138a820abb8d42225405be42fca7e80f2a
KodrAus
2023-05-05T00:16:06
just use the error message
diff --git a/src/lib.rs b/src/lib.rs index 177c1a1..ce3e820 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,7 +101,7 @@ where // infallible unless the writer itself fails match self.0.serialize(Formatter::new(f)) { Ok(()) => Ok(()), - Err(e) => write!(f, "<formatting failed: {...
1
3
3
883fc057aa630530f27d269ddad3f205016dfafb
KodrAus
2023-05-05T00:14:18
swallow errors when formatting
diff --git a/src/lib.rs b/src/lib.rs index 9c2b3b5..177c1a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,7 @@ where T: Serialize, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.serialize(Formatter::new(f)).map_err(Into::into) + fmt::Display::fmt(self, f) } } ...
1
17
3
8462a3acc0be8f84fca30b6cdba72d41492bcb3f
KodrAus
2023-05-03T23:13:51
repro panic in ToString
diff --git a/src/lib.rs b/src/lib.rs index 3dc55f0..9c2b3b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,12 +40,12 @@ fn takes_serialize(v: impl Serialize) { */ #![doc(html_root_url = "https://docs.rs/serde_fmt/1.0.2")] -#![no_std] +#![cfg_attr(not(test), no_std)] -#[cfg(not(feature = "std"))] +#[cfg(all(not(t...
1
18
6
cd92ab5f33a8d11de562287fec9a93841f777765
KodrAus
2023-04-08T10:59:06
use a better error message
diff --git a/src/lib.rs b/src/lib.rs index 9996f76..e916b23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -466,7 +466,7 @@ struct Error; impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "serde_fmt error") + write!(f, "failed to serialize to a standard forma...
1
1
1
a06287cf1a38819479097a46b552ab98249113ef
Ashley Mannix
2019-05-02T02:42:40
use an unstable feature to avoid buffering
diff --git a/Cargo.toml b/Cargo.toml index 1098b1b..306aa9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,10 @@ authors = ["Ashley Mannix <ashleymannix@live.com.au>"] edition = "2018" [features] +default = ["std"] + +std = ["serde/std"] [dependencies.serde] version = "1" -features = ["std"] default-featu...
2
74
84
e134cd6133a4e1cb2653b1e8b8eb844b6df60c01
KokaKiwi
2025-11-09T21:54:55
chore: fixup warning
diff --git a/src/lib.rs b/src/lib.rs index 99423d2..7bf251d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -452,8 +452,6 @@ pub fn encode_to_slice_upper<T: AsRef<[u8]>>( #[cfg(test)] mod test { use super::*; - #[cfg(feature = "alloc")] - use alloc::string::ToString; use pretty_assertions::assert_eq; ...
1
0
2
0bf4b24df058b818b597dec3e36836427e4d180b
KokaKiwi
2025-11-09T14:30:44
Apply suggestions from code review Co-authored-by: Lucas <24826124+Luro02@users.noreply.github.com>
diff --git a/src/lib.rs b/src/lib.rs index ebb834f..4f843ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,7 @@ extern crate alloc; #[cfg(feature = "alloc")] use alloc::{string::String, vec, vec::Vec}; -use core::{iter, u8}; +use core::iter; mod error; pub use crate::error::FromHexError; @@ -208,6 +208,1...
1
7
1
ded69481ee895ccaca6f8d85acedab026ed2f8ed
KokaKiwi
2025-11-09T00:49:49
refactor: improve code style and clarity in src/lib.rs - Remove unused `u8` import from `core` module - Add lint allow annotation for `__` constant to suppress non_upper_case_globals warning - Refactor `decode_in_slice()` to use slice-based `val()` function for cleaner implementation
diff --git a/src/lib.rs b/src/lib.rs index b72934b..bff7a58 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,7 +37,7 @@ extern crate alloc; #[cfg(feature = "alloc")] use alloc::{string::String, vec, vec::Vec}; -use core::{iter, u8}; +use core::iter; mod error; pub use crate::error::FromHexError; @@ -166,6 +166,7...
1
4
2
d2c5f0beb4421f9496da087aefc717f74018768b
KokaKiwi
2025-11-08T22:45:34
chore: remove obsolete docsrs configuration
diff --git a/Cargo.toml b/Cargo.toml index 09dcada..30c3120 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,4 +40,3 @@ serde_json = "1.0.133" [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/src/lib.rs b/src/lib.rs index ab84e63..ceace1a 100644 --- a/src/lib.rs +++ b/s...
2
0
3
2c270eb96f4d0d381a10eb7c004b7be789e23ab7
KokaKiwi
2025-11-08T01:12:19
test: fix test for unsized types
diff --git a/src/lib.rs b/src/lib.rs index e49dadb..ab84e63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -505,9 +505,17 @@ mod test { [0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72].encode_hex_upper::<String>(), "666F6F626172", ); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_...
1
11
3
fefd14434d0607ff2db0a79e8d8f12a73b8e2331
KokaKiwi
2025-11-07T16:39:56
style: cargo fmt
diff --git a/src/lib.rs b/src/lib.rs index 29514bf..e49dadb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -508,9 +508,6 @@ mod test { // test for unsize type. let s = &[0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]; - assert_eq!( - <[u8]>::encode_hex::<String>(s), - "666f6f626172".t...
1
1
4
cda9ef6de2115d0eb4c206bc9e42cc47ba30acf0
glorv
2024-10-18T09:40:50
lossen the ToHex requirement to support unsized type
diff --git a/src/lib.rs b/src/lib.rs index f51ef25..b3a66df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -129,7 +129,7 @@ fn encode_to_iter<T: iter::FromIterator<char>>(table: &'static [u8; 16], source: BytesToHexChars::new(source, table).collect() } -impl<T: AsRef<[u8]>> ToHex for T { +impl<T: AsRef<[u8]> + ?Si...
1
8
1
b3cd9736c106e69b7bb6b1507c05dc0aaf53028f
Jake Swensen
2025-07-26T01:46:29
fix: make FromHexError work with no_std thiserror `thiserror` requires `Eq` and an `Error` trait in order to derive an error like this: ``` #[error("Hex error: {0}")] HexError(#[from] hex::FromHexError), ``` Now that `Error` is part of core, that `Error` trait can be used instead of the one in `std`. This allows for...
diff --git a/src/error.rs b/src/error.rs index 1777ce7..5bb18b9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,7 +2,7 @@ use core::fmt; /// The error type for decoding a hex string into `Vec<u8>` or `[u8; N]`. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum From...
1
2
3
df45966c046571ca0084c80489452da7d68c1b77
Ross MacArthur
2025-07-06T13:51:08
Use `dep:serde` for `serde` feature
diff --git a/Cargo.toml b/Cargo.toml index 0c8065f..cd7c224 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ maintenance = { status = "actively-developed" } default = ["std"] alloc = [] std = ["alloc"] +serde = ["dep:serde"] [[bench]] name = "hex"
1
1
0
6f733caac525161d241dffec44daaa2d77d13426
Ross MacArthur
2025-07-06T13:50:57
Fix documentation feature labels on re-exports
diff --git a/src/serde.rs b/src/serde.rs index 773f298..da895e2 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT //! Hex encoding with `serde`. -#[cfg_attr( +#![cfg_attr( all(feature = "alloc", feature = "serde"), doc = r##" # Example @@ -36,6 +36,7...
1
3
1
b34fa8969803f3b63b5bccdd5c5f013be01904f8
Michal Nazarewicz
2023-07-19T16:05:43
Simplify encode_to_slice by using chunks_exact_mut Rather than using generate_iter to iterate over each 2-element chunks of output buffer, use chunks_exact_mut. This removes the need for the custom generate_iter function and makes the code shorter. Criterian shows improvement but to be honest I don’t trust those res...
diff --git a/src/lib.rs b/src/lib.rs index 5a2b93f..dac968e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -292,17 +292,6 @@ pub fn decode_to_slice<T: AsRef<[u8]>>(data: T, out: &mut [u8]) -> Result<(), Fr Ok(()) } -// generates an iterator like this -// (0, 1) -// (2, 3) -// (4, 5) -// (6, 7) -// ... -#[inline] -...
1
9
34
aed5965a4904bb0c7032aa5b40906a211c65e651
KokaKiwi
2024-11-19T13:36:54
style: Fix clippy lints
diff --git a/src/lib.rs b/src/lib.rs index f0d4166..5a2b93f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ impl<'a> BytesToHexChars<'a> { } } -impl<'a> Iterator for BytesToHexChars<'a> { +impl Iterator for BytesToHexChars<'_> { type Item = char; fn next(&mut self) -> Option<Self::Item> {...
1
2
2
bd83751b33d63c4aeab3d8a660884e25627ce15d
KokaKiwi
2024-11-19T13:05:56
test: Fix clippy lint name
diff --git a/tests/serde.rs b/tests/serde.rs index a571d3a..de24e69 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -1,5 +1,5 @@ #![cfg(all(feature = "serde", feature = "alloc"))] -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] use serde::{Deserialize, Serialize};
1
1
1
6dca9ce29703ed384080c188e0a77c947101daab
KokaKiwi
2024-11-19T13:00:08
test: Fix lint names
diff --git a/tests/version-number.rs b/tests/version-number.rs index c4f4084..3211148 100644 --- a/tests/version-number.rs +++ b/tests/version-number.rs @@ -1,4 +1,4 @@ -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] #[test] fn test_readme_deps() {
1
1
1
558a17c30b0478f5696d2726a98b874ed6d48e7c
KokaKiwi
2024-11-19T12:42:53
perf: Update benchmarks code
diff --git a/Cargo.toml b/Cargo.toml index b25d8dd..11c907a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,13 +27,14 @@ harness = false serde = { version = "1.0", default-features = false, optional = true } [dev-dependencies] -criterion = "0.3" -rustc-hex = "2.1" -faster-hex = "0.5" -version-sync = "0.9" -pretty_a...
2
40
22
108eadd1bb0985e7ac87480a58d76e0bd2c4c94b
KokaKiwi
2024-11-19T12:29:42
chore: Use SPDX license headers on source files
diff --git a/src/error.rs b/src/error.rs index ff7a3b5..94c2a7c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT use core::fmt; /// The error type for decoding a hex string into `Vec<u8>` or `[u8; N]`. diff --git a/src/lib.rs b/src/lib.rs index bc6a69d..16c...
3
4
7
83a2f6b34b9e0773ddb6831a703eee1ac2594b24
Jarkko Sakkinen
2023-12-02T02:39:13
feat: `decode_in_slice()` For memory constrained enviroments and network protocols being able to use memory without extra copies is a benefit. E.g. in my ZMODEM2 crate I need to do this for hex messages: ``` if encoding == Encoding::ZHEX { let mut tmp = [0; (FrameHeader::unescaped_size(Encoding::ZHEX) - 1) / 2]; ...
diff --git a/src/lib.rs b/src/lib.rs index bc6a69d..981cdec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -326,6 +326,30 @@ pub fn decode_to_slice<T: AsRef<[u8]>>(data: T, out: &mut [u8]) -> Result<(), Fr Ok(()) } +/// Decode a hex string into itself. +/// +/// Both, upper and lower case characters are valid in t...
1
24
0
8b9307bbb477b3b7af5ec7681c5a14528cda8f5a
Taiki Endo
2021-08-28T05:46:49
Add encode_to_slice_upper to improve performance of encode_upper This also fixes #45.
diff --git a/src/lib.rs b/src/lib.rs index 9a456c3..bdb029a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -276,7 +276,10 @@ pub fn encode<T: AsRef<[u8]>>(data: T) -> String { #[must_use] #[cfg(feature = "alloc")] pub fn encode_upper<T: AsRef<[u8]>>(data: T) -> String { - data.encode_hex_upper() + let data = data...
1
55
12
19b333d91cbbc58274cdcd948ef0b2f6078b5a2b
Taiki Endo
2021-08-28T04:51:30
Use chunks_exact_mut instead of generate_iter
diff --git a/src/lib.rs b/src/lib.rs index 28ff6c8..9a456c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -329,17 +329,6 @@ pub fn decode_to_slice<T: AsRef<[u8]>>(data: T, out: &mut [u8]) -> Result<(), Fr Ok(()) } -// generates an iterator like this -// (0, 1) -// (2, 3) -// (4, 5) -// (6, 7) -// ... -#[inline] -...
1
3
28
0129182ab8c57f9962c52367dc9665d69a3acab2
Taiki Endo
2021-08-28T04:50:31
Use encode_to_slice in encode
diff --git a/src/lib.rs b/src/lib.rs index 460f2a0..28ff6c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -257,7 +257,10 @@ from_hex_array_impl! { #[must_use] #[cfg(feature = "alloc")] pub fn encode<T: AsRef<[u8]>>(data: T) -> String { - data.encode_hex() + let data = data.as_ref(); + let mut out = vec![0; da...
1
4
1
97abf032d3430af4b2f6fa9b85806d99b2585b9d
Taiki Endo
2021-08-28T04:38:23
Adjust #[inline] on encoding functions
diff --git a/src/lib.rs b/src/lib.rs index bc6a69d..460f2a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,6 +102,7 @@ impl<'a> BytesToHexChars<'a> { impl<'a> Iterator for BytesToHexChars<'a> { type Item = char; + #[inline] fn next(&mut self) -> Option<Self::Item> { match self.next.take() { ...
1
1
1
f3251bd47d58ec3424a961dacda1b95df458fdd6
Taiki Endo
2021-07-18T09:45:39
Fix build errors
diff --git a/src/lib.rs b/src/lib.rs index a118bb9..4c993cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,9 +40,9 @@ #[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "alloc")] -use alloc::{string::String, vec::Vec}; +use alloc::{string::String, vec, vec::Vec}; -use core::iter; +use core::{iter, u8};...
2
2
4
3e2aa25cd58c6aca9aefec7c40cc48aa7c2b118b
Taiki Endo
2021-07-18T09:05:23
Inline decode_to_slice function
diff --git a/src/lib.rs b/src/lib.rs index 5aa79a8..a118bb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -339,6 +339,7 @@ pub fn decode<T: AsRef<[u8]>>(data: T) -> Result<Vec<u8>, FromHexError> { /// assert_eq!(hex::decode_to_slice("6b697769", &mut bytes as &mut [u8]), Ok(())); /// assert_eq!(&bytes, b"kiwi"); /// ``...
1
1
0
4fd0ed8d81c24785c44a33a54f7ccfeb94d13999
Taiki Endo
2021-07-18T08:36:44
Use decode_to_slice in Vec::from_hex
diff --git a/src/lib.rs b/src/lib.rs index f235ec3..5aa79a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,10 +225,9 @@ impl FromHex for Vec<u8> { return Err(FromHexError::OddLength); } - hex.chunks_exact(2) - .enumerate() - .map(|(i, pair)| val(pair, 2 * i)) - ...
1
3
4
ff1d11514e0eb7116aca65f8f69d58a061ee2382
Taiki Endo
2021-07-18T08:13:46
Use chunks_exact instead of chunks
diff --git a/src/lib.rs b/src/lib.rs index 04d5be6..f235ec3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,7 +225,7 @@ impl FromHex for Vec<u8> { return Err(FromHexError::OddLength); } - hex.chunks(2) + hex.chunks_exact(2) .enumerate() .map(|(i, pair)| v...
1
2
2
3b75b32a17153dc467fc403bbf60bf99fb9c0a72
Taiki Endo
2021-07-18T08:13:34
Inline val function
diff --git a/src/lib.rs b/src/lib.rs index 47ba8ab..04d5be6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,6 +196,7 @@ static DECODE_TABLE: [u8; 256] = [ __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // f ]; +#[inline] fn val(bytes: &[u8], idx: usize) -> Result<u8, FromHexError> { let ...
1
1
0
870590e2284250c4c8789955f7664d33dc15a2ae
Taiki Endo
2021-07-18T08:12:57
Use lookup table for decoding
diff --git a/src/lib.rs b/src/lib.rs index bc6a69d..47ba8ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,16 +172,46 @@ pub trait FromHex: Sized { fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error>; } -const fn val(c: u8, idx: usize) -> Result<u8, FromHexError> { - match c { - b'A'..=...
1
42
12
e8b40e42294f942302d153bec74dd4ef211650e9
Lucas
2021-06-06T08:52:36
Make `byte2hex` and `val` const functions
diff --git a/src/lib.rs b/src/lib.rs index afad856..bc6a69d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,7 +172,7 @@ pub trait FromHex: Sized { fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error>; } -fn val(c: u8, idx: usize) -> Result<u8, FromHexError> { +const fn val(c: u8, idx: usize) -> Res...
1
2
2
d98e58ebf2fe4317359026c7746f3c381e4ac7ac
Lucas
2021-06-06T08:42:19
Fix bad wording in the doc of encode_to_slice See https://github.com/KokaKiwi/rust-hex/issues/41
diff --git a/src/lib.rs b/src/lib.rs index 1e95b34..afad856 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -349,7 +349,7 @@ fn byte2hex(byte: u8, table: &[u8; 16]) -> (u8, u8) { /// Encodes some bytes into a mutable slice of bytes. /// -/// The output buffer, has to be able to hold at least `input.len() * 2` bytes, +/...
1
17
1
ba43579cc523f3b914b17ff0b66ec6e0c20062b2
Lucas
2021-06-06T08:23:55
Use const-generics to implement FromHex trait In rust version 1.51 a small subset of const-generics has been stabilized, which removes the need for the previously used macro.
diff --git a/src/lib.rs b/src/lib.rs index 1e95b34..f840c77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -201,44 +201,15 @@ impl FromHex for Vec<u8> { } } -// Helper macro to implement the trait for a few fixed sized arrays. Once Rust -// has type level integers, this should be removed. -macro_rules! from_hex_ar...
1
7
36
da8b5ee7ee30f085dc0491403e8db7450515ad88
KokaKiwi
2021-03-03T11:13:50
Fix tests.
diff --git a/src/lib.rs b/src/lib.rs index ec48961..1e95b34 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -387,6 +387,8 @@ mod test { use super::*; #[cfg(feature = "alloc")] use alloc::string::ToString; + #[cfg(feature = "alloc")] + use alloc::vec; use pretty_assertions::assert_eq; #[test...
1
2
0
e188c3d0d987948bd36af577f49e125d7375d85a
KokaKiwi
2021-03-03T10:36:20
Update dev-dependencies.
diff --git a/Cargo.toml b/Cargo.toml index f73a0a6..badf2eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,9 +28,9 @@ serde = { version = "1.0", default-features = false, optional = true } [dev-dependencies] criterion = "0.3" -rustc-hex = "2.0" -faster-hex = "0.4" -version-sync = "0.8" +rustc-hex = "2.1" +faster-h...
1
3
3
7fe0e5a8eb8b718c56178bda9ff73b55aff27161
KokaKiwi
2021-03-03T10:35:20
Fix formatting and some build warnings.
diff --git a/benches/hex.rs b/benches/hex.rs index 56b121f..6435032 100644 --- a/benches/hex.rs +++ b/benches/hex.rs @@ -35,34 +35,25 @@ fn bench_decode(c: &mut Criterion) { c.bench_function("faster_hex_decode", move |b| { let hex = faster_hex::hex_string(DATA).unwrap(); let len = DATA.len(); - ...
5
16
24
d8fa31fd9f73df9ea6ffeac8bfdb16154c7535f8
Dominik Spicher
2020-07-20T12:18:38
Fix typos in ToHex Doc comments
diff --git a/src/lib.rs b/src/lib.rs index 19ee759..e9fb779 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,11 +59,11 @@ pub use crate::serde::{deserialize, serialize, serialize_upper}; /// /// *Note*: instead of using this trait, you might want to use [`encode()`]. pub trait ToHex { - /// Encode the hex strict r...
1
2
2
be0c32f9c8938ca0359bbb0d1477e31b07cb3358
KokaKiwi
2020-02-18T16:38:32
fix: Bump to v0.4.2
diff --git a/Cargo.toml b/Cargo.toml index ba9c9fb..66801ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.4.1" +version = "0.4.2" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "Encoding and decoding data into/from hexadecimal representation." license =...
2
2
2
78359a859c356a6c756cccad16977fdedc4824c5
KokaKiwi
2020-02-10T02:41:26
Bump version (v0.4.1)
diff --git a/Cargo.toml b/Cargo.toml index 505be3b..ba9c9fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.4.0" +version = "0.4.1" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "Encoding and decoding data into/from hexadecimal representation." license =...
2
3
3
83a026176e6fffb43ccb5a0df84b29cbef260e86
KokaKiwi
2020-02-10T02:39:46
tests/serde: Fix test names
diff --git a/tests/serde.rs b/tests/serde.rs index 01f581d..aedf8c7 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -19,7 +19,7 @@ fn serialize() { } #[test] -fn dserialize() { +fn deserialize() { let foo = Foo { bar: vec![1, 10, 100], }; @@ -48,7 +48,7 @@ fn serialize_upper() { } #[test]...
1
2
2
b1d2318be1f19ed676b32ebb50bf3124705c471a
Luro02
2019-12-29T11:09:17
Fix broken tests Fix broken tests Fix minor mistake
diff --git a/src/error.rs b/src/error.rs index bd30dba..c65474f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -35,6 +35,8 @@ impl fmt::Display for FromHexError { #[cfg(test)] mod tests { use super::*; + #[cfg(not(feature = "std"))] + use alloc::string::ToString; use pretty_assertions::assert_eq; ...
2
4
0
764ee61536cbeb8cfbce6dba61c1b85398700bb6
Luro02
2019-12-29T10:12:12
Fix Error::InvalidHexCharacter::to_string
diff --git a/src/error.rs b/src/error.rs index a70ce6c..bd30dba 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,7 +24,7 @@ impl fmt::Display for FromHexError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Self::InvalidHexCharacter { c, index } => { - ...
1
2
2
f98cad4be7ba74e20d8a39843939ac05875e5368
Luro02
2019-12-29T10:11:17
Remove deprecated Error::description implementation https://doc.rust-lang.org/std/error/trait.Error.html#method.description
diff --git a/src/error.rs b/src/error.rs index 7c3c924..a70ce6c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,15 +18,7 @@ pub enum FromHexError { } #[cfg(feature = "std")] -impl std::error::Error for FromHexError { - fn description(&self) -> &str { - match *self { - Self::InvalidHexCharac...
1
1
27
fff3af1083073e50230b9c3d0646f210bb505b5b
Luro02
2019-12-29T10:03:23
Improvements to tests
diff --git a/Cargo.toml b/Cargo.toml index fb3ae04..0d10e72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,4 @@ criterion = "0.3" rustc-hex = "2.0" faster-hex = "0.4" version-sync = "0.8" +pretty_assertions = "0.6" diff --git a/src/error.rs b/src/error.rs index b19e550..7c3c924 100644 --- a/src/error.rs +++ b...
3
79
1
34fdc9a6bf40f0e2a7d44948f50a163e9ac4712e
Lucas
2019-12-28T16:34:36
Minor improvements to the documentation (#31) * minor improvements to the documentation * remove parenthesis
diff --git a/src/lib.rs b/src/lib.rs index befaf51..aba3429 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,19 +8,17 @@ // except according to those terms. //! Encoding and decoding hex strings. //! -//! For most cases, you can simply use the `decode()`, `encode()` and -//! `encode_upper()` functions. If you need a b...
1
10
9
c66909873ff2ca6dde649bfe7efd1ffd83fce42c
Lucas
2019-12-28T11:08:52
Add encode_to_slice (#32) * add encode_to_slice * change signature of `encode_to_slice`, to accept T: AsRef<[u8]>
diff --git a/src/lib.rs b/src/lib.rs index 2adb8ed..befaf51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -302,10 +302,83 @@ pub fn decode_to_slice<T: AsRef<[u8]>>(data: T, out: &mut [u8]) -> Result<(), Fr Ok(()) } +// generates an iterator like this +// (0, 1) +// (2, 3) +// (4, 5) +// (6, 7) +// ... +fn generat...
1
73
0
879b6e4cbe0af741d9539d3ff10b92d8d6a081eb
Luro02
2019-12-28T09:39:38
Move `FromHexError` to src/error.rs
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..b19e550 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,41 @@ +use core::fmt; + +/// The error type for decoding a hex string into `Vec<u8>` or `[u8; N]`. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum FromHexError { + /// An invalid chara...
2
44
41
bd77fe5b2c06d5e102725a4d620a16839515ba6b
Lucas
2019-10-08T17:20:35
Minor changes (#27) * update dependencies * use type alias for enums see here; https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html#referring-to-enum-variants-through-type-aliases * add clippy lint for unused type alias
diff --git a/Cargo.toml b/Cargo.toml index 6a840f2..542bc6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,6 @@ name = "hex" harness = false [dev-dependencies] -criterion = "0.2" +criterion = "0.3" rustc-hex = "2.0" -faster-hex = "0.3" +faster-hex = "0.4" diff --git a/src/lib.rs b/src/lib.rs index 9795f5b.....
2
9
8
e93f2c3f93ae0899b60e7aa6b187a9aa1627fdfb
KokaKiwi
2019-09-17T16:49:55
Bump version
diff --git a/Cargo.toml b/Cargo.toml index e41963e..6a840f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.3.2" +version = "0.4.0" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "Encoding and decoding data into/from hexadecimal representation." license =...
1
1
1
0adc0ac8011ebb2086ec03aac21f6c479ee82460
koushiro
2019-07-12T07:41:04
Migrate to 2018 edition Signed-off-by: koushiro <koushiro.cqx@gmail.com>
diff --git a/src/lib.rs b/src/lib.rs index dc6d346..a31865d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ #[cfg(not(feature = "std"))] extern crate alloc; #[cfg(not(feature = "std"))] -use alloc::{vec::Vec, string::String}; +use alloc::{string::String, vec::Vec}; use core::fmt; use core::iter; @@ -5...
1
4
4
ee1f74160ed81ba2b7f221919d113db52ccda113
koushiro
2019-07-11T02:17:25
Add no_std support Signed-off-by: koushiro <koushiro.cqx@gmail.com>
diff --git a/Cargo.toml b/Cargo.toml index e51a424..8ab26b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,9 @@ description = "Encoding and decoding data into/from hexadecimal representation." license = "MIT OR Apache-2.0" documentation = "https://docs.rs/hex/" repository = "https://github.com/KokaKiwi/rust-hex...
2
12
5
04fc5d25e530836baa7bef18ecd7e466fcb55f1b
KokaKiwi
2019-07-07T16:49:46
Fix deprecated triple-dots operator.
diff --git a/src/lib.rs b/src/lib.rs index b7a7dc3..f740690 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -199,9 +199,9 @@ pub trait FromHex: Sized { fn val(c: u8, idx: usize) -> Result<u8, FromHexError> { match c { - b'A'...b'F' => Ok(c - b'A' + 10), - b'a'...b'f' => Ok(c - b'a' + 10), - b'0...
1
3
3
b86f391835bf6984b472ebad25a5282a5cc7e0a9
KokaKiwi
2019-07-02T17:43:52
Replace encoding from using `fmt::Write` to `iter::FromIterator` Double benchmarks output.
diff --git a/src/lib.rs b/src/lib.rs index 19364f6..b7a7dc3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,8 +25,11 @@ //! } //! ``` +extern crate core; + use std::error; -use std::fmt; +use core::fmt; +use core::iter; /// Encoding values as hex string. /// @@ -38,44 +41,84 @@ use std::fmt; /// ``` /// use ...
1
69
35
0f99d77f9b64d1a064b790d8e2c32ac054b1b7bf
KokaKiwi
2018-08-02T13:17:30
Add decode_to_slice function, as a "generic" decoder
diff --git a/src/lib.rs b/src/lib.rs index 3b51e24..19364f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,20 +191,8 @@ macro_rules! from_hex_array_impl { type Error = FromHexError; fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> { - let hex = hex.as_ref(); ...
1
31
14
19fd37137686c30058bd9d11d21590e726ffdf31
KokaKiwi
2018-04-19T22:04:46
Bump patch version
diff --git a/Cargo.toml b/Cargo.toml index 06056a9..e51a424 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.3.1" +version = "0.3.2" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "Encoding and decoding data into/from hexadecimal representation." license =...
1
1
1
b376468610eced4353204cffbe487ca6276e0797
KokaKiwi
2018-04-19T22:04:31
Bump copyright year
diff --git a/src/lib.rs b/src/lib.rs index 6718bde..3b51e24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![cfg_attr(feature = "benchmarks", feature(test))] // Copyright (c) 2013-2014 The Rust Project Developers. -// Copyright (c) 2015-2017 The rust-hex Developers. +// Copyright (c) 2015-2018 The rust-h...
1
1
1
0c611bf6a2ac3c891246f2a7cfc45849feaa2da6
KokaKiwi
2018-04-19T21:59:29
Implement FromHex for a lot more array sizes (taken from another crate)
diff --git a/src/lib.rs b/src/lib.rs index a680e71..6718bde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -185,8 +185,8 @@ impl FromHex for Vec<u8> { // Helper macro to implement the trait for a few fixed sized arrays. Once Rust // has type level integers, this should be removed. -macro_rules! impl_from_hex_for_array...
1
26
27
60344e44abad3ba67e2dcc83be2f97e4331ab9d5
KokaKiwi
2018-04-19T21:49:43
Move duplicate code into a common function.
diff --git a/src/lib.rs b/src/lib.rs index c317ee4..a680e71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,28 +54,28 @@ pub trait ToHex { fn write_hex_upper<W: fmt::Write>(&self, w: &mut W) -> fmt::Result; } +fn hex_write<W: fmt::Write>(table: &[u8; 16], src: &[u8], w: &mut W) -> fmt::Result { + let hex = |...
1
14
14
a9956db4b044771f180699727cc772556a960b4d
Jake Goulding
2018-01-28T21:26:06
Add basic benchmarks
diff --git a/Cargo.toml b/Cargo.toml index 21262ed..06056a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,6 @@ description = "Encoding and decoding data into/from hexadecimal representation." license = "MIT OR Apache-2.0" documentation = "https://docs.rs/hex/" repository = "https://github.com/KokaKiwi/rust-hex...
2
25
0
76a83021a1d38cd0e11416c57e50579d1e567054
KokaKiwi
2017-11-13T16:48:12
Bump version to 0.3.1
diff --git a/Cargo.toml b/Cargo.toml index 631eb5c..21262ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.3.0" +version = "0.3.1" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "Encoding and decoding data into/from hexadecimal representation." license =...
1
1
1
7c6b97c79b4bad635eb5fc1543d2da359d093b7c
KokaKiwi
2017-11-13T16:16:40
Bump version to 0.3.0
diff --git a/Cargo.toml b/Cargo.toml index a342798..631eb5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.2.0" +version = "0.3.0" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "Encoding and decoding data into/from hexadecimal representation." license =...
1
1
1
1c303c8fb781b689107ee22c8678b27fc7bea413
Daniel Wagner-Hall
2017-11-11T17:22:53
Add some other multiples of 8
diff --git a/src/lib.rs b/src/lib.rs index e9e90c6..b50881e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,7 +225,14 @@ impl_from_hex_for_array!(13); impl_from_hex_for_array!(14); impl_from_hex_for_array!(15); impl_from_hex_for_array!(16); + +// Throw in some multiples of 8 which may be useful. +impl_from_hex_for_...
1
7
0
42e3c1ee5b90ec854eda00fd8e968fb6266d84df
Daniel Wagner-Hall
2017-10-25T09:32:25
Implement FromHex for 32-byte arrays
diff --git a/src/lib.rs b/src/lib.rs index 36867c6..e9e90c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,6 +225,7 @@ impl_from_hex_for_array!(13); impl_from_hex_for_array!(14); impl_from_hex_for_array!(15); impl_from_hex_for_array!(16); +impl_from_hex_for_array!(32); /// Encodes `data` as hex string using low...
1
1
0
9fa1a487c2b7a7df2829e2c3c7c9316634569155
Lukas Kalbertodt
2017-07-10T06:32:44
Fix formatting of tests Visual indent is bad, as decided in the fmt-rfcs repo.
diff --git a/src/lib.rs b/src/lib.rs index 7ef99cc..36867c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -301,35 +301,49 @@ mod test { #[test] pub fn test_from_hex_okay_str() { - assert_eq!(Vec::from_hex("666f6f626172").unwrap(), - b"foobar"); - assert_eq!(Vec::from_hex("666F6...
1
38
22
18a86c9b506aaf63469734d41b1fb797b6e3433f
Lukas Kalbertodt
2017-07-10T06:30:43
Fix copy&paste typo and add a comment about fixed sized arrays
diff --git a/src/lib.rs b/src/lib.rs index 5b5c0d3..7ef99cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ pub trait ToHex { /// are used (e.g. `f9b4ca`). fn write_hex<W: fmt::Write>(&self, w: &mut W) -> fmt::Result; - /// Writes the hex string representing `self` into `w`. Lower case letters...
1
3
1
a9b0d6f059ffa20eebf502047c3346ebaeae12ad
Lukas Kalbertodt
2017-05-12T17:48:05
Fix Cargo metadata - The `homepage` field shouldn't be set if it's pointing to the same location as another link-field (like repository) - docs.rs is usually preferred over self-hosted docs - Fix description to include "decoding"
diff --git a/Cargo.toml b/Cargo.toml index 78bce9b..a342798 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,8 +2,7 @@ name = "hex" version = "0.2.0" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] -description = "A basic crate to encode values to hexadecimal representation." +description = "Encoding and decoding data ...
1
2
3
4d6cc4edcf077fd7790ce80b1866e10d709afa7a
Lukas Kalbertodt
2017-05-12T17:35:28
Extend and slightly modify API & add documentation This is a BREAKING CHANGE. The `ToHex` trait now requires the `write_hex` method and doesn't have a `to_hex` method anymore. It makes sense to make the required methods as general as possible. In this case, making the method converting to `String` required and `write...
diff --git a/src/lib.rs b/src/lib.rs index c8b359e..5b5c0d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,49 +6,104 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. +//! Encoding and decoding hex s...
1
244
51
1e7195f48d2672fcd1751b4923228efdbbb517ce
KokaKiwi
2016-03-28T11:39:49
Bump version to 0.2.0
diff --git a/Cargo.toml b/Cargo.toml index 7cad6ab..78bce9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex" -version = "0.1.0" +version = "0.2.0" authors = ["KokaKiwi <kokakiwi@kokakiwi.net>"] description = "A basic crate to encode values to hexadecimal representation." license = "M...
1
1
1
71c83f2349d847ec95bf1ee6080ecdc7ca665037
Corey Farwell
2016-03-27T19:34:15
Stop accepting whitespace in `FromHex::from_hex`. As discussed in https://github.com/KokaKiwi/rust-hex/issues/4.
diff --git a/src/lib.rs b/src/lib.rs index 75bf578..b269769 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,10 +76,6 @@ impl FromHex for Vec<u8> { b'A'...b'F' => buf |= byte - b'A' + 10, b'a'...b'f' => buf |= byte - b'a' + 10, b'0'...b'9' => buf |= byte - b'0', - ...
1
9
4
1f64da574ab531f48933f7e2d09d2fbd37a911f6
Corey Farwell
2016-03-27T19:30:48
Update `FromHex::from_hex` to take `AsRef<[u8]>`. As discussed in https://github.com/KokaKiwi/rust-hex/issues/4.
diff --git a/src/lib.rs b/src/lib.rs index 75bf578..5f66b65 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,21 +58,22 @@ impl fmt::Display for FromHexError { pub trait FromHex: Sized { type Error; - fn from_hex(s: &str) -> Result<Self, Self::Error>; + fn from_hex<T: AsRef<[u8]>>(s: T) -> Result<Self, Self...
1
16
8