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.
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Trait Implementations§
Source§impl Layer for SmtpLayer
impl Layer for SmtpLayer
Source§fn header_len(&self, buf: &[u8]) -> usize
fn header_len(&self, buf: &[u8]) -> usize
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Source§impl LayerDispatch for SmtpLayer
impl LayerDispatch for SmtpLayer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Source§fn dispatch_set_field(
&self,
_buf: &mut [u8],
_name: &str,
_value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, _buf: &mut [u8], _name: &str, _value: FieldValue, ) -> Option<Result<(), FieldError>>
Auto Trait Implementations§
impl Freeze for SmtpLayer
impl RefUnwindSafe for SmtpLayer
impl Send for SmtpLayer
impl Sync for SmtpLayer
impl Unpin for SmtpLayer
impl UnsafeUnpin for SmtpLayer
impl UnwindSafe for SmtpLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more