camino

UTF-8 encoded path types for Rust: Utf8Path and Utf8PathBuf as drop-in std::path replacements.

Library
Cargo
v1.2.5
575stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
67/100Good
Development Activity72
Maintenance68
Community40
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
87/100Excellent
Architecture88
Code Quality90
Innovation80
Learning Curve88

camino is a Rust crate that extends std::path with Utf8Path and Utf8PathBuf, path types that are guaranteed to contain only valid UTF-8. Because the standard library’s Path and PathBuf may hold non-Unicode data, code that assumes UTF-8 must repeatedly call to_str().unwrap(); camino lets you validate encoding once at the boundary and then work with paths as strings for free.

The types are thin, near-drop-in replacements for their std counterparts, implementing Display and exposing str-returning accessors while keeping the familiar std::path API. This is ideal for tools like Cargo and any system that lists file names in metadata, where UTF-8 paths are a safe and simplifying assumption.

What You Get

  • Utf8Path and Utf8PathBuf types guaranteed to hold only valid UTF-8
  • Near-drop-in compatibility with std::path::Path and PathBuf APIs
  • Display and str-returning accessors without repeated to_str().unwrap()
  • Optional serde and proptest integrations behind feature flags
  • Dual MIT / Apache-2.0 licensing and a stable, mature API

Common Use Cases

  • Building CLI tools and build systems (like Cargo) that only handle UTF-8 paths
  • Eliminating repeated to_str().unwrap() calls in path-heavy code
  • Serializing and deserializing paths as plain strings via serde

Under The Hood

Architecture - camino is a thin wrapper over std::path. Utf8PathBuf owns a validated String and Utf8Path is an unsized borrowed view, mirroring the PathBuf/Path relationship. Construction validates UTF-8 once (fallible from OsStr-based paths, infallible from str), after which the whole std::path-style API is re-exposed but returns &str where std would return OsStr. A build.rs handles feature/version detection.

Tech Stack - Rust, with only optional dependencies: serde_core (behind a serde feature) for string-based (de)serialization and proptest (behind a proptest feature) for property-based testing. It ships a camino-examples crate demonstrating integration with serde and clap.

Code Quality - A mature, heavily-used crate (200M+ downloads) with a maintained CHANGELOG, clippy config, rustfmt config, a tests directory, and release tooling. The design mirrors std closely so behavior is predictable and the audit surface is small.

API Design - Deliberately a drop-in for std::path: the same method names and semantics, differing only where str replaces OsStr. This makes adoption near-mechanical for existing code while permanently removing the to_str().unwrap() dance, and the optional serde/clap integrations cover common real-world plumbing.

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