pub fn bearer(value: &[u8]) -> Result<Option<&[u8]>, ParseError>Expand description
The Bearer token of an Authorization value (RFC 6750 section 2.1):
Some(token) when the scheme is Bearer (case-insensitive), None for
another scheme.
§Errors
ErrorKind::Empty for Bearer alone; ErrorKind::InvalidByte when
the payload is not a b64token; ErrorKind::TrailingData; the scheme
errors.
§Examples
assert_eq!(parse_net::bearer(b"Bearer abc123")?, Some(&b"abc123"[..]));
assert_eq!(parse_net::bearer(b"Basic dXNlcjpwYXNz")?, None);
assert!(parse_net::bearer(b"Bearer").is_err());