Skip to content

Commit

Permalink
blobby: use base16ct instead of hex
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jun 19, 2024
1 parent c68a520 commit 8765320
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
62 changes: 34 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blobby/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ categories = ["no-std"]
edition = "2018"

[dev-dependencies]
hex = "0.4"
base16ct = { version = "0.2", features = ["std"] }
4 changes: 2 additions & 2 deletions blobby/examples/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{env, error::Error, fs::File};
fn encode(reader: impl BufRead, mut writer: impl Write) -> io::Result<usize> {
let mut blobs = Vec::new();
for line in reader.lines() {
let blob = hex::decode(line?.as_str())
let blob = base16ct::mixed::decode_vec(line?.as_str())
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
blobs.push(blob);
}
Expand Down Expand Up @@ -34,7 +34,7 @@ fn decode<R: BufRead, W: Write>(mut reader: R, mut writer: W) -> io::Result<usiz
format!("invalid blobby data: {:?}", e),
)
})?;
writer.write_all(hex::encode(blob).as_bytes())?;
writer.write_all(base16ct::lower::encode_string(blob).as_bytes())?;
writer.write_all(b"\n")?;
}
Ok(res.len())
Expand Down

0 comments on commit 8765320

Please sign in to comment.