[−][src]Struct milter::Context
Context supplied to the milter callbacks.
The Context
struct enables some connection-local operations, most
importantly macro lookup with macro_value
. It also provides access to
connection-local user data
.
Safety
The type parameter T
specifies the type of the value to be retrieved from
the data
handle. Retrieving the data is potentially an unsafe operation,
as the data needs to be materialised from a raw C pointer. Take care not to
introduce a mismatch when specifying T
; one milter application should
always pick the same type across callbacks.
Fields
data: DataHandle<T>
A handle on user data associated with this context.
Methods
impl<T> Context<T>
[src]
pub fn new(ptr: *mut SMFICTX) -> Self
[src]
Constructs a new Context
from the milter library-supplied raw context
pointer.
You do not normally need to use new
; a Context
is already supplied
to the callbacks.
Panics
Panics if ptr
is null.
pub fn macro_value(&self, name: &str) -> Result<Option<&str>>
[src]
Returns the value for the given macro if present.
Errors
If conversion of arguments or return values at the boundary to the milter library fails, an error variant is returned.
Examples
let ip_address = context.macro_value("{daemon_addr}")?;
pub fn set_requested_macros(&self, stage: Stage, macros: &str) -> Result<()>
[src]
Requests that the space-separated macros
be made available in the
given stage. This method may only be called once for each Stage
variant; calls per stage are not cumulative.
This method is part of the negotiation procedure and should therefore
only be called in the negotiate
stage.
This action is enabled with the flag Actions::SET_REQUESTED_MACROS
.
Errors
An error variant is returned if type conversion at the FFI boundary fails, or if the underlying milter library returns a failure status.
Examples
context.set_requested_macros(Stage::Helo, "{cert_issuer} {cert_subject}")?;
pub fn set_error_reply(
&self,
code: &str,
ext_code: Option<&str>,
msg_lines: Vec<&str>
) -> Result<()>
[src]
&self,
code: &str,
ext_code: Option<&str>,
msg_lines: Vec<&str>
) -> Result<()>
Sets the default SMTP error reply code for the current connection.
The three-digit SMTP reply code (RFC 5321) may be enhanced with an optional extended status code (RFC 3463), and with an optional multi-line text message.
This setting only takes effect when the first digit of the reply code
matches the Status
returned from the callback: "4xx"
for
Tempfail
, "5xx"
for Reject
.
Errors
An error variant is returned if type conversion at the FFI boundary fails, or if the underlying milter library returns a failure status.
Panics
Panics if msg_lines
contains more than 32 elements.
Examples
context.set_error_reply("550", Some("5.7.0"), vec![ "Access rejected.", "Rejection is due to the sending MTA's poor reputation.", ])?;
Trait Implementations
Auto Trait Implementations
impl<T> !Send for Context<T>
impl<T> !Sync for Context<T>
impl<T> Unpin for Context<T>
impl<T> UnwindSafe for Context<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> !RefUnwindSafe for Context<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,