Crate fluent_uri
source ·Expand description
A full-featured URI reference handling library compliant with RFC 3986.
Examples: Parsing. Building. Reference resolution. Normalization. Percent-decoding. Percent-encoding.
§Terminology
This crate provides a struct UriRef representing a URI reference,
that is, either a URI or a relative reference. If it starts with a scheme
(like http, ftp, mailto, etc.) followed by a colon (:), it is a URI. For example,
http://example.com/ and mailto:user@example.com are URIs. Otherwise, it is
a relative reference. For example, //example.org/, /index.html, ../, foo,
?bar, and #baz are relative references.
You can combine parse and is_uri to check whether
a string is a valid URI, for example:
fn is_valid_uri(s: &str) -> bool {
fluent_uri::UriRef::parse(s).is_ok_and(|r| r.is_uri())
}
assert!(is_valid_uri("http://example.com/"));
assert!(!is_valid_uri("foo"));§Guidance for crate users
Advice for designers of new URI schemes can be found in RFC 7595. Guidance on the specification of URI substructure in standards can be found in RFC 8820. The crate author recommends RFC 9413 for further reading as the long-term interoperability of URI schemes may be of concern.
§Crate features
-
net(default): Enablesstd::netsupport. Required for IP address fields inHostandAuthority::socket_addrs. Disablingnetwill not affect the behavior ofUriRef::parse. -
std(default): Enablesstdsupport. Required forErrorimplementations andAuthority::socket_addrs. Disablingstdwhile enablingnetrequirescore::netand a minimum Rust version of1.77. -
serde: Enablesserdesupport. Required forSerializeandDeserializeimplementations onUriRef.
Modules§
- Components of URI reference.
- Utilities for percent-encoding.
- Error types.
Structs§
- A builder for URI reference.
- A URI reference, i.e., either a URI or a relative reference.