faup-rs: Fast URL Parser for Rust
A high-performance, zero-allocation URL parser for Rust that handles:
- Hostnames (with subdomains, custom TLDs, and IDNs)
- IPv4/IPv6 addresses
- User credentials (username/password)
- Ports, paths, queries, and fragments
- UTF-8 and URL-encoded characters
Features
✅ Zero-allocation parsing: Borrows input strings where possible
✅ Public Suffix List (PSL): Correctly identifies domain suffixes
✅ Custom TLDs: Extendable via the CUSTOM_TLDS
constant
✅ Comprehensive error handling: Clear, actionable error types
✅ UTF-8 support: Full Unicode handling for all URL components
Installation
Add to your Cargo.toml
:
[]
= "0.1"
Usage
Basic Parsing
use Url;
let url = parse.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Hostname Components
use ;
let url = parse.unwrap;
if let Hostname = url.host
IP Addresses
use Url;
let url = parse.unwrap;
assert!;
User Info (UTF-8 Support)
use Url;
let url = parse.unwrap;
let user_info = url.userinfo.unwrap;
assert_eq!;
assert_eq!;
Custom TLDs
use Url;
let url = parse.unwrap;
assert_eq!;
Examples
Real-World URLs
use Url;
let urls = ;
for url_str in urls
License
This project is licensed under the GNU General Public License v3.0 (GPLv3)..