Callbacks

Struct Callbacks 

Source
pub struct Callbacks<T: Send> {
Show 13 fields pub negotiate: Option<Box<dyn for<'cx> Fn(&'cx mut NegotiateContext<T>, Actions, ProtoOpts) -> CallbackFuture<'cx> + Send + Sync>>, pub connect: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString, SocketInfo) -> CallbackFuture<'cx> + Send + Sync>>, pub helo: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString) -> CallbackFuture<'cx> + Send + Sync>>, pub mail: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, Vec<CString>) -> CallbackFuture<'cx> + Send + Sync>>, pub rcpt: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, Vec<CString>) -> CallbackFuture<'cx> + Send + Sync>>, pub data: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>, pub header: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString, CString) -> CallbackFuture<'cx> + Send + Sync>>, pub eoh: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>, pub body: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, Bytes) -> CallbackFuture<'cx> + Send + Sync>>, pub eom: Option<Box<dyn for<'cx> Fn(&'cx mut EomContext<T>) -> CallbackFuture<'cx> + Send + Sync>>, pub abort: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>, pub close: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>, pub unknown: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString) -> CallbackFuture<'cx> + Send + Sync>>,
}
Expand description

Callback closures for each milter stage.

Consult the sendmail documentation for the purpose of each callback and the meaning of its arguments. Here is an overview of the callback flow:

The callbacks indicated may be called repeatedly.

The SMTP protocol allows multiple messages to be transmitted in a single connection, so the message-scoped callback flow may be traversed multiple times.

During the message-scoped stages, abort is called when processing of the current message is aborted.

The callback unknown is called for unknown SMTP commands.

Fields§

§negotiate: Option<Box<dyn for<'cx> Fn(&'cx mut NegotiateContext<T>, Actions, ProtoOpts) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the negotiate stage.

§connect: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString, SocketInfo) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the connect stage.

§helo: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the helo stage.

§mail: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, Vec<CString>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the mail stage.

§rcpt: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, Vec<CString>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the rcpt stage.

§data: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the data stage.

§header: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString, CString) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the header stage.

§eoh: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the eoh stage.

§body: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, Bytes) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the body stage.

§eom: Option<Box<dyn for<'cx> Fn(&'cx mut EomContext<T>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the eom stage.

§abort: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the abort stage.

§close: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the close stage.

§unknown: Option<Box<dyn for<'cx> Fn(&'cx mut Context<T>, CString) -> CallbackFuture<'cx> + Send + Sync>>

The callback for the unknown stage.

Implementations§

Source§

impl<T: Send> Callbacks<T>

Source

pub fn new() -> Self

Returns a new, empty collection of callbacks.

Source

pub fn on_negotiate( self, callback: impl Fn(&mut NegotiateContext<T>, Actions, ProtoOpts) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the negotiate stage.

Source

pub fn on_connect( self, callback: impl Fn(&mut Context<T>, CString, SocketInfo) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the connect stage.

Source

pub fn on_helo( self, callback: impl Fn(&mut Context<T>, CString) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the helo stage.

Source

pub fn on_mail( self, callback: impl Fn(&mut Context<T>, Vec<CString>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the mail stage.

Source

pub fn on_rcpt( self, callback: impl Fn(&mut Context<T>, Vec<CString>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the rcpt stage.

Source

pub fn on_data( self, callback: impl Fn(&mut Context<T>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the data stage.

Source

pub fn on_header( self, callback: impl Fn(&mut Context<T>, CString, CString) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the header stage.

Source

pub fn on_eoh( self, callback: impl Fn(&mut Context<T>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the eoh stage.

Source

pub fn on_body( self, callback: impl Fn(&mut Context<T>, Bytes) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the body stage.

Source

pub fn on_eom( self, callback: impl Fn(&mut EomContext<T>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the eom stage.

Source

pub fn on_abort( self, callback: impl Fn(&mut Context<T>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the abort stage.

Source

pub fn on_close( self, callback: impl Fn(&mut Context<T>) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the close stage.

Source

pub fn on_unknown( self, callback: impl Fn(&mut Context<T>, CString) -> CallbackFuture<'_> + Send + Sync + 'static, ) -> Self

Configures the callback for the unknown stage.

Trait Implementations§

Source§

impl<T: Default + Send> Default for Callbacks<T>

Source§

fn default() -> Callbacks<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Callbacks<T>

§

impl<T> !RefUnwindSafe for Callbacks<T>

§

impl<T> Send for Callbacks<T>

§

impl<T> Sync for Callbacks<T>

§

impl<T> Unpin for Callbacks<T>

§

impl<T> !UnwindSafe for Callbacks<T>

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> 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 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, 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.
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