pub struct SmtpLayer {
pub index: LayerIndex,
}Expand description
A zero-copy view into an SMTP layer within a packet buffer.
Fields§
§index: LayerIndexImplementations§
Source§impl SmtpLayer
impl SmtpLayer
pub fn new(index: LayerIndex) -> Self
pub fn at_start(len: usize) -> Self
Sourcepub fn is_response(&self, buf: &[u8]) -> bool
pub fn is_response(&self, buf: &[u8]) -> bool
Returns true if this message is a server reply (3-digit code).
Sourcepub fn is_multiline(&self, buf: &[u8]) -> bool
pub fn is_multiline(&self, buf: &[u8]) -> bool
Returns true if this is a multi-line reply.
Sourcepub fn reply_code(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn reply_code(&self, buf: &[u8]) -> Result<u16, FieldError>
Returns the 3-digit reply code.
§Errors
Returns FieldError::BufferTooShort if fewer than 3 bytes are available,
or FieldError::InvalidValue if the first 3 bytes are not ASCII digits.
Sourcepub fn reply_text(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn reply_text(&self, buf: &[u8]) -> Result<String, FieldError>
Returns the reply text (after the code and separator).
§Errors
Returns FieldError::InvalidValue if the payload does not begin with a
valid 3-digit reply code.
Sourcepub fn command(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn command(&self, buf: &[u8]) -> Result<String, FieldError>
Returns the command verb (for client commands).
§Errors
Returns FieldError::InvalidValue if the payload is not valid UTF-8.
Sourcepub fn args(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn args(&self, buf: &[u8]) -> Result<String, FieldError>
Returns the command arguments.
§Errors
Returns FieldError::InvalidValue if the payload is not valid UTF-8.
Sourcepub fn mailfrom(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn mailfrom(&self, buf: &[u8]) -> Result<String, FieldError>
Extracts the MAIL FROM address from a MAIL command.
Input: MAIL FROM:<user@example.com>
Output: user@example.com
§Errors
Returns FieldError::InvalidValue if the payload is not a MAIL FROM command.
Sourcepub fn rcptto(&self, buf: &[u8]) -> Result<String, FieldError>
pub fn rcptto(&self, buf: &[u8]) -> Result<String, FieldError>
Extracts the RCPT TO address from a RCPT command.
Input: RCPT TO:<user@example.com>
Output: user@example.com
§Errors
Returns FieldError::InvalidValue if the payload is not a RCPT TO command.