hex

Encode and decode data to and from hexadecimal in Rust, with no_std and serde support.

Library
Cargo
v0.4.3
268stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
37/100Needs Attention
Development Activity4
Maintenance0
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
89/100Excellent
Architecture82
Code Quality90
Innovation88
Learning Curve95

hex is a small, dependency-light Rust crate for converting bytes to and from their hexadecimal string representation. Originally extracted from rustc-serialize, it exposes simple top-level encode/decode functions for the common case plus the ToHex and FromHex traits when you need finer control over allocation and output types.

The crate is #![forbid(unsafe_code)] and works in no_std environments through configurable std, alloc, and serde feature flags, making it suitable for everything from application code to embedded targets. It also provides slice-based APIs that let you encode and decode without heap allocation.

What You Get

  • Top-level encode, encode_upper, and decode helpers for the common string case
  • ToHex and FromHex traits implemented for any AsRef<[u8]> and for Vec<u8>/[u8; N]
  • Allocation-free encode_to_slice and decode_to_slice APIs for fixed buffers and no_std
  • Optional serde integration via #[serde(with = "hex")] for de/serializing byte fields
  • A precise FromHexError enum distinguishing invalid characters, odd length, and bad buffer size

Common Use Cases

  • Rendering binary data such as hashes, keys, or checksums as readable hex strings
  • Parsing hex-encoded input from config files, CLIs, or wire formats back into bytes
  • Serializing Vec<u8> fields as hex in JSON and other serde-driven formats
  • Encoding and decoding on embedded or no_std targets without heap allocation

Under The Hood

Architecture

The crate is a single flat module in src/lib.rs with two supporting files, src/error.rs (the FromHexError enum) and src/serde.rs (optional serde glue). Encoding is driven by a BytesToHexChars iterator that walks a byte slice, splitting each byte into high and low nibbles and indexing a static 16-entry lookup table (HEX_CHARS_LOWER/HEX_CHARS_UPPER); it implements ExactSizeIterator so encode can preallocate the output String. Decoding maps each ASCII hex character back to a nibble via val() and recombines pairs, surfacing structured errors for invalid characters, odd input length, or mismatched fixed-buffer sizes. Public entry points layer from the ergonomic encode/decode free functions down to the ToHex/FromHex traits and the allocation-free encode_to_slice/decode_to_slice variants.

Tech Stack

Pure Rust on the 2018 edition with an MSRV of 1.85 and no required runtime dependencies. serde (v1.0) is the only optional dependency, gated behind the serde feature. Feature flags form a small lattice — default = ["std"], std = ["alloc"], and standalone alloc and serde — so the crate degrades cleanly from full std down to no_std. Dev-dependencies (criterion, data-encoding, rustc-hex, faster-hex, version-sync, pretty_assertions, serde_json) drive benchmarks against competing crates and version-consistency checks.

Code Quality

High. The crate is #![forbid(unsafe_code)] and #![cfg_attr(not(feature = "std"), no_std)], and its public API is thoroughly documented with runnable doctests. Tests live inline in src/lib.rs and src/error.rs plus integration tests in tests/serde.rs and a version-sync check in tests/version-number.rs, covering round-trips, odd-length and invalid-character errors, empty input, whitespace rejection, and fixed-array decoding. Error handling is explicit through the FromHexError enum rather than panics, and naming (encode_to_slice, decode_to_slice, encode_upper) is consistent and predictable.

API Design

Excellent developer experience. The one-liner hex::encode/hex::decode functions cover the majority of use cases with zero boilerplate, while the ToHex/FromHex traits — blanket-implemented for any AsRef<[u8]> and for Vec<u8>/[u8; N] — give power users control over output type and allocation. The slice-based APIs support no_std and hot paths, and serde integration is a single #[serde(with = "hex")] attribute. Documentation is published on docs.rs with clear examples, making the crate approachable within minutes.

Used by 26 apps in this directory

TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Swift
64%
GPL 3.0

cmux

Developer Tools · AI Development

26,221

A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.

View details
84
Repo Health
81
Technical
72
Dependency
Built with
Swift64%
Rust14%
Updated today
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
Rust
50%
Other

hoodik

File Storage · Security

1,446

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
74
Repo Health
71
Technical
65
Dependency
Built with
Rust50%
TypeScript33%
Vue15%
Updated 4 days ago
Rust
41%
Other

Hook0

Devops

1,477

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
Updated today
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
Rust
72%
Other

iii

Developer Tools · Devops

18,604

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
86
Repo Health
85
Technical
69
Dependency
Built with
Rust72%
TypeScript17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search