Skip to main content

Module link

Module link 

Source
Expand description

Link (RFC 8288 section 3): #link-value, where link-value = "<" URI-Reference ">" *( OWS ";" OWS link-param ) and link-param = token BWS [ "=" BWS ( token / quoted-string ) ].

The target is validated as RFC 3986 characters with well-formed %XX triples and returned unresolved (url-lib resolves). Commas inside <...> do not split. A title* is decoded at parse time, as filename* is, so a view never holds an undecodable title.

§Examples

use parse_net::{parse_link, Limits};

let links = parse_link(b"<https://x.test/p?page=2,3>; rel=\"next last\", </a>; rel=prev; crossorigin", &Limits::DEFAULT)?;
let all: Vec<_> = links.iter().collect();
assert_eq!(all[0].target(), b"https://x.test/p?page=2,3");
assert!(all[0].has_rel("last") && all[1].has_rel("prev"));

Structs§

HreflangIter
The hreflang values of a link value.
LinkIter
The link values of a validated Links.
LinkParamIter
The parameters of a validated LinkParams.
LinkParams
The parameters of a link value.
LinkValue
One link value: a target and its parameters.
Links
A validated Link value.
RelIter
The relation types of a rel value.

Functions§

parse_link
Parses a Link field value.
write_link
Writes one link value: <target>; name=value for each parameter, values through write_word. An empty value writes the name alone (; crossorigin), which parses back as a parameter with no value.