Struct vsmtp_rule_engine::RuleEngine
[−]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
impl RuleEngine
pub fn new(config: &Config, script_path: &Option<PathBuf>) -> Result<Self>
pub fn new(config: &Config, script_path: &Option<PathBuf>) -> 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_pathas a valid module folder. - failed to compile or load any script located at
script_path.
pub fn from_script(config: &Config, script: &str) -> Result<Self>
pub fn from_script(config: &Config, script: &str) -> Result<Self>
pub fn run_when(
&self,
rule_state: &mut RuleState,
smtp_state: &StateSMTP
) -> Status
pub fn run_when(
&self,
rule_state: &mut RuleState,
smtp_state: &StateSMTP
) -> 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,
state: &StateSMTP,
config: &Config,
resolvers: Arc<Resolvers>,
mail_context: MailContext,
mail_message: MessageBody
) -> (MailContext, MessageBody, Status, Option<Status>)
pub fn just_run_when(
&self,
state: &StateSMTP,
config: &Config,
resolvers: Arc<Resolvers>,
mail_context: MailContext,
mail_message: MessageBody
) -> (MailContext, MessageBody, Status, Option<Status>)
pub fn new_compiler(config: &Config) -> Engine
pub fn new_compiler(config: &Config) -> Engine
create a rhai engine to compile all scripts with vsl’s configuration.
pub fn compile_api(engine: &Engine) -> Result<Module>
pub fn compile_api(engine: &Engine) -> Result<Module>
compile vsl’s api into a module.
Errors
- Failed to compile the API.
- Failed to create a module from the API.
Auto Trait Implementations
impl !RefUnwindSafe for RuleEngine
impl Send for RuleEngine
impl Sync for RuleEngine
impl Unpin for RuleEngine
impl !UnwindSafe for RuleEngine
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more