#![doc = include_str!("../README.md")]
#![doc(html_no_source)]
#![deny(missing_docs)]
#![warn(rust_2018_idioms)]
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
#![warn(clippy::cargo)]
#![allow(elided_lifetimes_in_paths)]
macro_rules! block_on {
($future:expr) => {
tokio::task::block_in_place(move || tokio::runtime::Handle::current().block_on($future))
};
}
mod dsl {
pub mod cmd;
pub mod directives;
pub mod smtp;
}
pub use dsl::cmd::new_module as new_module_cmd;
pub use dsl::smtp::new_module as new_module_smtp;
pub use rhai;
#[macro_use]
mod error;
mod execution_stage;
mod rule_engine;
mod rule_state;
mod server_api;
pub use dsl::directives::Directive;
pub use execution_stage::ExecutionStage;
pub use rule_engine::RuleEngine;
pub use rule_state::RuleState;
mod domain_hierarchy {
#[cfg(feature = "builder")]
pub mod builder;
pub mod tree;
}
#[cfg(feature = "builder")]
pub use domain_hierarchy::builder::Builder;
pub use domain_hierarchy::tree::SubDomainHierarchy;
#[cfg(test)]
mod tests;
pub mod api {
use crate::server_api::ServerAPI;
use vsmtp_mail_parser::MessageBody;
pub type EngineResult<T> = Result<T, Box<rhai::EvalAltResult>>;
pub type Context = std::sync::Arc<std::sync::RwLock<vsmtp_common::Context>>;
pub type Message = std::sync::Arc<std::sync::RwLock<MessageBody>>;
pub type Server = std::sync::Arc<ServerAPI>;
pub use vsmtp_plugin_vsl::objects::{Object, SharedObject};
pub mod auth;
pub mod code;
pub mod dkim;
pub mod dmarc;
pub mod dns;
pub mod envelop;
pub mod fs;
pub mod logging;
pub mod mail_context;
pub mod message;
pub mod net;
pub mod spf;
pub mod state;
pub mod time;
pub mod transports;
pub mod utils;
#[macro_export]
macro_rules! get_global {
($ncc:expr, ctx) => {
$ncc.call_fn::<$crate::api::Context>("ctx", ())
.expect("`ctx` do not exist in the `ncc`")
};
($ncc:expr, srv) => {
$ncc.call_fn::<$crate::api::Server>("srv", ())
.expect("`srv` do not exist in the `ncc`")
};
($ncc:expr, msg) => {
$ncc.call_fn::<$crate::api::Message>("msg", ())
.expect("`msg` do not exist in the `ncc`")
};
}
#[must_use]
pub fn vsmtp_static_modules() -> [(&'static str, rhai::Module); 20] {
[
("state", rhai::exported_module!(state)),
("envelop", rhai::exported_module!(envelop)),
("code", rhai::exported_module!(code)),
("net", rhai::exported_module!(net)),
("time", rhai::exported_module!(time)),
("dns", rhai::exported_module!(dns)),
("fs", rhai::exported_module!(fs)),
("logging", rhai::exported_module!(logging)),
("auth", rhai::exported_module!(auth)),
("spf", rhai::exported_module!(spf)),
("dkim", rhai::exported_module!(dkim)),
("dmarc", rhai::exported_module!(dmarc)),
("transport", rhai::exported_module!(transports)),
("utils", rhai::exported_module!(utils)),
("ctx", rhai::exported_module!(mail_context)),
("msg", rhai::exported_module!(message)),
("obj", vsmtp_plugin_vsl::object_module()),
("unix", vsmtp_plugin_vsl::unix_module()),
("cmd", crate::dsl::cmd::new_module()),
("smtp", crate::dsl::smtp::new_module()),
]
}
}