pub struct RuleEngine { /* private fields */ }
Expand description

a sharable rhai engine. contains an ast representation of the user’s parsed .vsl script files, and modules / packages to create a cheap rhai runtime.

Implementations§

§

impl RuleEngine

pub fn new( config: Arc<Config>, resolvers: Arc<DnsResolvers>, queue_manager: Arc<dyn GenericQueueManager> ) -> Result<Self>

creates a new instance of the rule engine, reading all files in the script_path parameter. if script_path is None, a warning is emitted and a deny-all script is loaded.

Errors
  • failed to register script_path as a valid module folder.
  • failed to compile or load any script located at script_path.

pub fn srv(&self) -> Arc<ServerAPI>

pub fn spawn_at_connect( &self, client_addr: SocketAddr, server_addr: SocketAddr, server_name: Domain, timestamp: OffsetDateTime, uuid: Uuid ) -> Arc<RuleState>

pub fn spawn_finished( &self, mail_context: Context, message: MessageBody ) -> Arc<RuleState>

build a cheap rhai engine with vsl’s api.

pub fn run_when( &self, rule_state: &RuleState, skipped: &mut Option<Status>, smtp_state: ExecutionStage ) -> Status

Runs all rules from a stage using the current transaction state.

the server_address parameter is used to distinguish logs from each other, printing the address & port associated with this run session, not the current context. (because the context could have been pulled from the filesystem when receiving delegation results)

Panics

pub fn just_run_when( &self, skipped: &mut Option<Status>, state: ExecutionStage, mail_context: Context, mail_message: MessageBody ) -> (Context, MessageBody, Status)

Instantiate a RuleState and run it for the only state provided

Return

A tuple with the mail context, body, result status, and skip status.

pub fn new_rhai_engine() -> Engine

create a rhai engine to compile all scripts with vsl’s configuration.

pub fn build_global_modules(engine: &mut Engine) -> Result<Vec<Shared<Module>>>

Build vsl global modules.

Errors
  • Failed to build modules.

pub fn build_static_modules( engine: &mut Engine, config: &Config ) -> Result<Vec<(String, Shared<Module>)>>

Build vsl static modules.

Errors
  • Failed to build modules.

pub fn is_handled_domain(&self, domain: &Domain) -> bool

Return true if the given domain or any parent domain is handled by the configuration.

pub fn get_delegation_directive_bound_to_address( &self, socket: SocketAddr ) -> Option<&Directive>

Find the delegate directive that matches the given socket.

Trait Implementations§

§

impl Debug for RuleEngine

§

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

Formats the value using the given formatter. 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, 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