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
Sourcepub async fn abort(self) -> Result<(), ProtocolError>
pub async fn abort(self) -> Result<(), ProtocolError>
Auto Trait Implementations§
impl<RW> Freeze for Connection<RW>where
RW: Freeze,
impl<RW> RefUnwindSafe for Connection<RW>where
RW: RefUnwindSafe,
impl<RW> Send for Connection<RW>where
RW: Send,
impl<RW> Sync for Connection<RW>where
RW: Sync,
impl<RW> Unpin for Connection<RW>
impl<RW> UnwindSafe for Connection<RW>where
RW: UnwindSafe,
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> 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