Struct Connection

Source
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:

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>

Source

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

Source

pub async fn helo<C: Into<Helo>>( &mut self, command: C, ) -> Result<(), ResponseError>

Handle a client helo

§Errors

Errors on any response from the milter server that is not Continue

Source

pub async fn mail<C: Into<Mail>>( &mut self, command: C, ) -> Result<(), ResponseError>

Send the sender info

§Errors

Errors on any response from the milter server that is not Continue

Source

pub async fn recipient<C: Into<Recipient>>( &mut self, command: C, ) -> Result<(), ResponseError>

Send the recipient info

§Errors

Errors on any response from the milter server that is not Continue

Source

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

Source

pub async fn header<C: Into<Header>>( &mut self, command: C, ) -> Result<(), ResponseError>

Send headers

§Errors

Errors on any response from the milter server that is not Continue

Source

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

Source

pub async fn body<C: Into<Body>>( &mut self, command: C, ) -> Result<(), ResponseError>

Send a body part

§Errors

Errors on any response from the milter server that is not Continue

Source

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

Source

pub async fn modification(&mut self) -> Result<CommandType, ResponseError>

Receive all modification requests from the server

§Errors

Errors on error regarding server communication

Source

pub async fn quit(self) -> Result<(), ProtocolError>

Ask for a graceful connection shutdown

§Errors

Errors on io or codec Errors

Source

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

Source

pub async fn abort(self) -> Result<(), ProtocolError>

Abort processing for the current mail

§Errors

Errors on io or codec Errors

Source

pub async fn unknown<C: Into<Unknown>>( &mut self, command: C, ) -> Result<(), ResponseError>

Send an unknown command to the server.

§Errors

Errors on io or codec Errors

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.