pub enum Context {
    Connect(ContextConnect),
    Helo(ContextHelo),
    MailFrom(ContextMailFrom),
    RcptTo(ContextRcptTo),
    Finished(ContextFinished),
}
Expand description

A step-by-step SMTP envelop produced by the transaction

Variants§

§

Connect(ContextConnect)

§

Helo(ContextHelo)

§

MailFrom(ContextMailFrom)

§

RcptTo(ContextRcptTo)

§

Finished(ContextFinished)

Implementations§

§

impl Context

pub fn stage(&self) -> Stage

Get the current SMTP stage of the transaction

pub fn reset(&mut self)

Called when a “RSET” is issued

pub fn new( client_addr: SocketAddr, server_addr: SocketAddr, server_name: Domain, timestamp: OffsetDateTime, uuid: Uuid ) -> Self

Convert the context to a [ContextConnect]

pub fn to_helo( &mut self, client_name: ClientName, using_deprecated: bool ) -> Result<&mut Self, Error>

Convert the context to a [ContextHelo] or overwrite the existing one

Errors

pub fn with_credentials( &mut self, credentials: Credentials ) -> Result<(), Error>

Set the credentials used by the client during the SASL handshake

Errors

pub fn to_mail_from( &mut self, reverse_path: Option<Address> ) -> Result<(), Error>

Convert the context to a [ContextMailFrom] or overwrite the existing one

Errors

pub fn to_finished(&mut self) -> Result<(), Error>

Convert the context to a [ContextFinished]

Errors

pub fn set_skipped(&mut self, status: Status)

pub fn connection_timestamp(&self) -> &OffsetDateTime

Get the timestamp of the TCP/IP connection

pub fn connection_uuid(&self) -> &Uuid

Get the uuid of the TCP/IP connection

pub fn client_addr(&self) -> &SocketAddr

Get the address of the socket client

pub fn server_addr(&self) -> &SocketAddr

Get the address of the socket server which accepted the connection

pub fn server_name(&self) -> &Domain

Get the name of the server which the client connected to.

pub fn is_secured(&self) -> bool

Is the connection been encrypted using the SMTP+TLS protocol?

pub fn is_authenticated(&self) -> bool

Is the connection been authenticated using the SMTP+SASL protocol?

pub fn to_secured( &mut self, sni: Option<Domain>, protocol_version: ProtocolVersion, cipher_suite: CipherSuite, peer_certificates: Option<Vec<Certificate>>, alpn_protocol: Option<Vec<u8>> ) -> Result<(), Error>

Set the TlsProperties of the connection.

Errors

pub fn client_name(&self) -> Result<&ClientName, Error>

Get the name of the client.

Errors

pub fn tls(&self) -> &Option<TlsProperties>

Get the TlsProperties of the connection.

pub fn auth(&self) -> &Option<AuthProperties>

Get the AuthProperties of the connection.

pub fn auth_mut(&mut self) -> Option<&mut AuthProperties>

Get the mutable reference AuthProperties of the connection.

pub fn to_auth(&mut self) -> Result<&mut AuthProperties, Error>

Set the AuthProperties of the connection.

Errors

pub fn reverse_path(&self) -> Result<&Option<Address>, Error>

Get the reverse path.

Errors

pub fn set_reverse_path( &mut self, reverse_path: Option<Address> ) -> Result<(), Error>

Set the reverse path.

Errors

pub fn mail_timestamp(&self) -> Result<&OffsetDateTime, Error>

Get the time::OffsetDateTime when the MAIL FROM has been received.

Errors

pub fn message_uuid(&self) -> Result<&Uuid, Error>

Get the message id

Errors

pub fn generate_message_id(&mut self) -> Result<(), Error>

Generate a new message id in the context

Errors

pub fn add_forward_path( &mut self, forward_path: Address, transport: Arc<dyn AbstractTransport> ) -> Result<(), Error>

Add a recipient at the end of the list of forward paths. If the state was Stage::MailFrom, the state is changed to Stage::RcptTo.

Errors

pub fn remove_forward_path( &mut self, forward_path: &Address ) -> Result<bool, Error>

Remove the first recipient with the address forward_path. Return false if no such recipient exist

Errors

pub fn forward_paths(&self) -> Result<&Vec<Address>, Error>

Get a reference of the forwards path.

Errors

pub fn forward_paths_mut(&mut self) -> Result<&mut Vec<Address>, Error>

Get a mutable reference of the forwards path.

Errors

pub fn set_transport_for_one( &mut self, search: &Address, transport: Arc<dyn AbstractTransport> ) -> Result<(), Error>

Set a delivery transport for a recipients.

Errors

pub fn set_transport_foreach( &mut self, transport: Arc<dyn AbstractTransport> ) -> Result<(), Error>

Set a delivery transport for all recipients.

Errors

pub fn delivery(&self) -> Result<&HashMap<WrapperSerde, DeliverTo>, Error>

Errors

pub fn delivery_mut( &mut self ) -> Result<&mut HashMap<WrapperSerde, DeliverTo>, Error>

Errors

pub fn transaction_type(&self) -> Result<&TransactionType, Error>

Get the TransactionType.

Errors

pub fn set_transaction_type( &mut self, transaction_type: TransactionType ) -> Result<(), Error>

Set the TransactionType. If the state was Stage::MailFrom, the state is changed to Stage::RcptTo.

Errors

pub fn spf(&self) -> Result<Option<&Result>, Error>

Get the spf::Result.

Errors

pub fn set_spf(&mut self, spf: Result) -> Result<(), Error>

Set the spf::Result.

Errors

pub fn dkim(&self) -> Result<Option<&VerificationResult>, Error>

Get the dkim::VerificationResult if it exists.

Errors

pub fn set_dkim(&mut self, result: VerificationResult) -> Result<(), Error>

pub fn unwrap_finished(self) -> Result<ContextFinished, Error>

Convert the instance into a [ContextFinished].

Errors

Trait Implementations§

§

impl Clone for Context

§

fn clone(&self) -> Context

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Context

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Serialize for Context

§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more