pub struct Reply {
pub code: u16,
pub lines: Vec<String>,
/* private fields */
}Expand description
A complete SMTP reply, possibly assembled from multiple continuation lines.
Fields§
§code: u16The three-digit reply code, shared by every line of the reply.
lines: Vec<String>One entry per line, in the order received. Each entry is the line’s
text portion (after the code and separator) decoded as UTF-8 with
invalid sequences replaced by U+FFFD. The text retains any
enhanced status code prefix; use Self::message_text to obtain
the same text with the prefix stripped, or Self::enhanced to
obtain the parsed code itself.
Implementations§
Source§impl Reply
impl Reply
Sourcepub fn new(code: u16, lines: Vec<String>) -> Self
pub fn new(code: u16, lines: Vec<String>) -> Self
Construct a reply with the given code and lines, with no enhanced
status code attached. The client adds an enhanced code via the
internal attach_enhanced_status setter when the session has
ENHANCEDSTATUSCODES enabled.
Sourcepub fn joined_text(&self) -> String
pub fn joined_text(&self) -> String
Reply text concatenated with \n. Suitable for diagnostics.
If an enhanced status code prefix is present, it is preserved in
the output; use Self::message_text for a presentation that
hides it.
§Caveat for log handlers
The returned String may contain \n (used internally to
separate multi-line replies). It does not contain \r —
CRLF is stripped by the reply parser before storage — but
applications that forward this text to line-oriented loggers
(syslog, journald, structured JSON, etc.) should still
escape or render newlines explicitly to avoid log injection
where one logical reply renders as multiple log records. The
same caveat applies to anything else that consumes the
Display output of crate::ProtocolError or
crate::AuthError, since those types embed reply text.
Sourcepub fn message_text(&self) -> String
pub fn message_text(&self) -> String
Reply text with any enhanced status code prefix stripped from each line. Suitable for human-facing error messages where the code is shown separately. Lines that have no enhanced prefix are returned unchanged.
Sourcepub fn enhanced(&self) -> Option<EnhancedStatus>
pub fn enhanced(&self) -> Option<EnhancedStatus>
Parsed enhanced status code, if the server has provided one and the session has it enabled.
Sourcepub fn iter_lines(&self) -> impl Iterator<Item = &str>
pub fn iter_lines(&self) -> impl Iterator<Item = &str>
Iterate over the trimmed text of each line. Useful for parsing EHLO
capabilities, where the first line contains the greeting and the
remaining lines each name a single capability (e.g. AUTH LOGIN,
PIPELINING, 8BITMIME).
Sourcepub fn try_parse_enhanced(&self) -> Option<EnhancedStatus>
pub fn try_parse_enhanced(&self) -> Option<EnhancedStatus>
Parse an enhanced status code from the first line’s text, if
present. Used by the client to populate self.enhanced only when
the session has ENHANCEDSTATUSCODES enabled.