pub fn parse_addr_spec(value: &[u8]) -> Result<AddrSpec<'_>, ParseError>Expand description
Parses an addr-spec (RFC 5322 section 3.4.1) without obsolete forms,
comments, or folding: a dot-atom or quoted local part, @, and a
dot-atom domain or [domain-literal]. The local part is at most 64
octets and the address at most 254; non-ASCII is accepted only as valid
UTF-8 (RFC 6532). Surrounding SP and HTAB are stripped.
§Errors
ErrorKind::InvalidAddrSpec (a leading, trailing, or doubled dot, a
missing @, a comment, a byte outside the grammar);
ErrorKind::TooLong; ErrorKind::InvalidUtf8;
ErrorKind::UnterminatedQuote.
§Examples
use parse_net::mail::{self, Domain};
let a = mail::parse_addr_spec(b"user@[192.0.2.1]")?;
assert_eq!(a.domain, Domain::Literal(b"192.0.2.1"));
assert!(!mail::parse_addr_spec("j\u{f6}rg@example.de".as_bytes())?.is_ascii());
assert!(mail::parse_addr_spec(b"user(comment)@example.com").is_err());