Rust

header

Module

Header fields, from a name and a value to bytes a server will accept: encoded words for anything outside ASCII, split so none exceeds its limit, and folding so no line runs long.

Contents

use utopia_smtp::mime::header::line;
Rust
pub fn line(name: &str, value: &str) -> Result<String, Error>

One field, folded and terminated by CRLF. A value outside ASCII becomes RFC 2047 encoded words. The value must already be free of line endings.

A space-free run longer than 998 octets cannot be folded and is an Error::InvalidArgument.

Rust
use utopia_smtp::mime::header;

assert_eq!(header::line("Subject", "Hellö")?, "Subject: =?UTF-8?B?SGVsbMO2?=\r\n");
use utopia_smtp::mime::header::phrase;
Rust
pub fn phrase(value: &str) -> String

A display name for use inside a structured value: quoted (with " and \ escaped) when ASCII, encoded words otherwise.

Rust
use utopia_smtp::mime::header;

assert_eq!(header::phrase("Jane Doe"), "\"Jane Doe\"");
assert_eq!(header::phrase("Jäne"), "=?UTF-8?B?SsOkbmU=?=");