Skip to main content

basic

Function basic 

Source
pub fn basic(value: &[u8]) -> Result<Option<&[u8]>, ParseError>
Expand description

The base64 text of a Basic Authorization value (RFC 7617): Some when the scheme is Basic, None for another scheme. The text is checked (the base64 alphabet, padding only at the end, a length that is a multiple of four) and not decoded.

§Errors

ErrorKind::InvalidBase64; ErrorKind::Empty for Basic alone; the scheme errors.

§Examples

assert_eq!(parse_net::basic(b"Basic dXNlcjpwYXNz")?, Some(&b"dXNlcjpwYXNz"[..]));
assert_eq!(parse_net::basic(b"Bearer abc123")?, None);
assert!(parse_net::basic(b"Basic YQ").is_err());