pub struct Connection<RW: AsyncRead + AsyncWrite + Unpin> { /* private fields */ }Expand description
A single milter connection
This can be created by calling Client::connect_via to establish
a milter session.
A regular session could use these commands in order:
Connection::connectConnection::heloConnection::mailConnection::recipientConnection::dataConnection::header(multiple)Connection::end_of_headerConnection::body(multiple)Connection::end_of_body
Be careful about the ordering of these commands, milter implementations are designed to expect them in order they appear in the SMTP protocol.
§Protocol from OptNeg
Depending on what was set by client and server during option negotiation when establishing the connection, commands might either not be sent at all or no response is awaited.
Assuming Protocol::NO_HELO is
set during option negotiation, calling Connection::helo short-circuits
to return Ok(()).
If Protocol::NR_HELO is set,
calling Connection::helo does not wait for an answer from the milter
server, it immediately return Ok(()) after sending the command.
Commands behave differently here, see the implementations for
Protocol::skip_send and
Protocol::skip_response
for details.
Implementations§
Source§impl<RW: AsyncRead + AsyncWrite + Unpin> Connection<RW>
impl<RW: AsyncRead + AsyncWrite + Unpin> Connection<RW>
Sourcepub async fn connect<C: Into<Connect>>(
&mut self,
command: C,
) -> Result<(), ResponseError>
pub async fn connect<C: Into<Connect>>( &mut self, command: C, ) -> Result<(), ResponseError>
Send connect information.
§Errors
Errors on any response from the milter server that is not Continue
Sourcepub async fn recipient<C: Into<Recipient>>(
&mut self,
command: C,
) -> Result<(), ResponseError>
pub async fn recipient<C: Into<Recipient>>( &mut self, command: C, ) -> Result<(), ResponseError>
Sourcepub async fn data(&mut self) -> Result<(), ResponseError>
pub async fn data(&mut self) -> Result<(), ResponseError>
Indicate that data follows
§Errors
Errors on any response from the milter server that is not Continue
Sourcepub async fn end_of_header(&mut self) -> Result<(), ResponseError>
pub async fn end_of_header(&mut self) -> Result<(), ResponseError>
Indicate all headers have been sent
§Errors
Errors on any response from the milter server that is not Continue
Sourcepub async fn end_of_body(
&mut self,
) -> Result<ModificationResponse, ResponseError>
pub async fn end_of_body( &mut self, ) -> Result<ModificationResponse, ResponseError>
Indicate all body parts have been sent
§Errors
Errors on any response from the milter server that is not Continue
Sourcepub async fn modification(&mut self) -> Result<CommandType, ResponseError>
pub async fn modification(&mut self) -> Result<CommandType, ResponseError>
Receive all modification requests from the server
§Errors
Errors on error regarding server communication
Sourcepub async fn quit(self) -> Result<(), ProtocolError>
pub async fn quit(self) -> Result<(), ProtocolError>
Sourcepub fn quit_nc(self) -> Result<(), ProtocolError>
pub fn quit_nc(self) -> Result<(), ProtocolError>
Ask to re-use this connection for a new mail
§Errors
Errors on any response from the milter server that is not Continue