[][src]Struct milter::ActionContext

pub struct ActionContext<T> {
    pub data: DataHandle<T>,
    // some fields omitted
}

Context supplied to the eom milter callback, where message-modifying actions can be taken.

The ActionContext struct supports the same operations as Context. The safety note regarding Context applies here as well.

Important: Action methods may only be called if they have been configured with Milter::actions or during negotiation.

Fields

data: DataHandle<T>

A handle on user data associated with this context.

Methods

impl<T> ActionContext<T>[src]

pub fn new(ptr: *mut SMFICTX) -> Self[src]

Constructs a new ActionContext from the milter library-supplied raw context pointer.

You do not normally need to use new; an ActionContext is already supplied to the on_eom callback.

Panics

Panics if ptr is null.

pub fn macro_value(&self, name: &str) -> Result<Option<&str>>[src]

pub fn set_error_reply(
    &self,
    code: &str,
    ext_code: Option<&str>,
    msg_lines: Vec<&str>
) -> Result<()>
[src]

pub fn replace_sender(
    &self,
    mail_from: &str,
    esmtp_args: Option<&str>
) -> Result<()>
[src]

Replaces the envelope sender (MAIL FROM address) of the current message with mail_from. Optional additional ESMTP arguments to the MAIL command may be given in esmtp_args.

This action is enabled with the flag Actions::REPLACE_SENDER.

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

pub fn add_recipient(
    &self,
    rcpt_to: &str,
    esmtp_args: Option<&str>
) -> Result<()>
[src]

Adds envelope recipient (RCPT TO address) rcpt_to to the current message. Optional additional ESMTP arguments to the RCPT command may be given in esmtp_args.

This action is enabled with two distinct flags:

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

pub fn remove_recipient(&self, rcpt_to: &str) -> Result<()>[src]

Removes envelope recipient (RCPT TO address) rcpt_to from the current message.

This action is enabled with the flag Actions::REMOVE_RECIPIENT.

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

pub fn add_header(&self, name: &str, value: &str) -> Result<()>[src]

Appends a header to the list of headers of the current message. If the header value is to span multiple lines, use \n (followed by whitespace) as the line separator, not \r\n.

This action is enabled with the flag Actions::ADD_HEADER.

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

Examples

context.add_header(
    "Content-Type",
    "multipart/signed; micalg=pgp-sha512;
\tprotocol=\"application/pgp-signature\"; boundary=\"=-=-=\"",
)?;

pub fn insert_header(&self, index: usize, name: &str, value: &str) -> Result<()>[src]

Inserts a header at index in the list of headers of the current message. If the header value is to span multiple lines, use \n (followed by whitespace) as the line separator, not \r\n.

This action is enabled with the flag Actions::ADD_HEADER.

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

pub fn replace_header(
    &self,
    name: &str,
    index: usize,
    value: Option<&str>
) -> Result<()>
[src]

Replaces (or removes, or appends) a header at the index’th occurrence of headers with the given name for the current message. The index is 1-based (starts at 1).

More precisely,

  • replaces the index’th occurrence of headers named name with the specified value;
  • if the value is None, the header is instead removed;
  • if index is greater than the number of occurrences of headers named name, a new header is instead appended.

If the header value is to span multiple lines, use \n (followed by whitespace) as the line separator, not \r\n.

This action is enabled with the flag Actions::REPLACE_HEADER.

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

pub fn append_new_body_chunk(&self, content: &[u8]) -> Result<()>[src]

Appends a chunk of bytes to the new message body of the current message.

This method may be called repeatedly: initially empty, the new body is augmented with additional content with each call. If this method is not called, the original message body remains unchanged.

This action is enabled with the flag Actions::REPLACE_BODY.

Errors

An error variant is returned if the milter library returns a failure status.

pub fn quarantine(&self, reason: &str) -> Result<()>[src]

Quarantines the current message for the given reason.

This action is enabled with the flag Actions::QUARANTINE.

Errors

An error variant is returned if type conversion at the FFI boundary fails, or if the milter library returns a failure status.

pub fn keepalive(&self) -> Result<()>[src]

Signals to the milter library that this milter is still active, causing it to reset timeouts.

Errors

An error variant is returned if the milter library returns a failure status.

Trait Implementations

impl<T: Debug> Debug for ActionContext<T>[src]

Auto Trait Implementations

impl<T> !Send for ActionContext<T>

impl<T> !Sync for ActionContext<T>

impl<T> Unpin for ActionContext<T>

impl<T> UnwindSafe for ActionContext<T> where
    T: RefUnwindSafe

impl<T> !RefUnwindSafe for ActionContext<T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]