[][src]Trait postfix_policy::PolicyRequestHandler

pub trait PolicyRequestHandler<'l, ContextType, ErrorType> {
    fn new(ctx: &'l ContextType) -> Self;
fn attribute(&mut self, name: &[u8], value: &[u8]) -> Option<ErrorType>;
fn response(self) -> Result<PolicyResponse, ErrorType>; }

Handler for policy requests.

Will be instanciated for every request by calling new with the ctx passed to handle_connection. handle_connection will then call attribute for every attribute in the policy request and then response to get the response.

Required methods

fn new(ctx: &'l ContextType) -> Self

Creates a new instance and initalizes it with the context ContextType.

fn attribute(&mut self, name: &[u8], value: &[u8]) -> Option<ErrorType>

Attribute name with value value was part of the request. If this method returns Some(error), handling of the request is cancelled immediately and handle_connection will return Err(error). If this method returns None, request handling will continue normally.

fn response(self) -> Result<PolicyResponse, ErrorType>

Returns the desired action after all attributes were processed. If this method returns Err(error), handling of the request is cancelled immediately and handle_connection will return Err(error). If this method returns Ok(policy_response), the policy_response will be sent to the Server. This completes the request.

Loading content...

Implementors

Loading content...