Function link_strict

Source
pub fn link_strict<'a, E>(
    input: &'a str,
) -> Result<Vec<Option<LinkData<'a>>>, LinkParseError>
where E: ParseError<&'a str>, Err<VerboseError<&'a str>>: From<Err<E>>,
Expand description

This method will parse a &str and return an array of Options if it can successfully parse the &str as a Link header. The reason we return Options is because if the Link header has empty elements, we want to show that information to the user by returning Nones.

use nom_rfc8288::complete::{link_strict, LinkData, LinkParam};

let link_data = r#"<https://example.com>; rel="origin"; csv="one,two""#;
let parsed = link_strict(link_data).unwrap();

assert_eq!(
    parsed,
    vec![
        Some(
            LinkData {
                url: "https://example.com",
                params: vec![
                    LinkParam {
                        key: "rel",
                        val: Some("origin".to_owned()),
                    },
                    LinkParam {
                        key: "csv",
                        val: Some("one,two".to_owned()),
                    }
                ],
            }
        ),
    ]
);