Skip to content

Add Request::name() method returning SMTP command name#13

Open
edevil wants to merge 1 commit intostalwartlabs:mainfrom
edevil:add-request-name-method
Open

Add Request::name() method returning SMTP command name#13
edevil wants to merge 1 commit intostalwartlabs:mainfrom
edevil:add-request-name-method

Conversation

@edevil
Copy link
Contributor

@edevil edevil commented Feb 25, 2026

Summary

Add a name() method to Request<T> that returns the SMTP command name as a &'static str (e.g. "EHLO", "MAIL", "RCPT", "QUIT").

This is useful for logging, tracing, and metrics where consumers need a human-readable label for the command variant. Currently every consumer of this crate has to write their own match expression to map request variants to command name strings — this is trivial boilerplate that belongs in the library.

Example

let req = Request::parse(&mut input.iter())?.into_owned();
println!("Received command: {}", req.name()); // "MAIL", "RCPT", "EHLO", etc.

Changes

  • Added impl<T> Request<T> block with pub fn name(&self) -> &'static str in src/lib.rs
  • Added request_name test in src/request/parser.rs

Add a name() method to Request<T> that returns the SMTP command name as
a &'static str (e.g. "EHLO", "MAIL", "RCPT", "QUIT").

This is useful for logging, tracing, and metrics where consumers need a
human-readable label for the command variant. Currently every consumer
has to write their own match expression for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant