diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index e2b24cc..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,13 +0,0 @@ -# These are supported funding model platforms - -github: stalwartlabs -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4d9636b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.showUnlinkedFileNotification": false +} \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index 7e00751..ce7c837 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +sieve-rs 0.5.0 +================================ +- Removed context. + sieve-rs 0.4.0 ================================ - Support for expressions. diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index ce69be4..18fd567 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -330,7 +330,7 @@ impl Compiler { self } - pub fn register_functions(mut self, fnc_map: &mut FunctionMap) -> Self { + pub fn register_functions(mut self, fnc_map: &mut FunctionMap) -> Self { self.functions = std::mem::take(&mut fnc_map.map); self } diff --git a/src/lib.rs b/src/lib.rs index ab6f872..fca33e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -289,6 +289,7 @@ pub struct Sieve { num_match_vars: usize, } +#[derive(Clone)] pub struct Compiler { // Settings pub(crate) max_script_size: usize, @@ -307,16 +308,16 @@ pub struct Compiler { pub(crate) functions: AHashMap, } -pub type Function = for<'x> fn(&'x Context<'x, C>, Vec) -> Variable; +pub type Function = for<'x> fn(&'x Context<'x>, Vec) -> Variable; #[derive(Default, Clone)] -pub struct FunctionMap { +pub struct FunctionMap { pub(crate) map: AHashMap, - pub(crate) functions: Vec>, + pub(crate) functions: Vec, } #[derive(Debug, Clone)] -pub struct Runtime { +pub struct Runtime { pub(crate) allowed_capabilities: AHashSet, pub(crate) valid_notification_uris: AHashSet>, pub(crate) valid_ext_lists: AHashSet>, @@ -325,7 +326,7 @@ pub struct Runtime { pub(crate) metadata: Vec<(Metadata, Cow<'static, str>)>, pub(crate) include_scripts: AHashMap>, pub(crate) local_hostname: Cow<'static, str>, - pub(crate) functions: Vec>, + pub(crate) functions: Vec, pub(crate) max_nested_includes: usize, pub(crate) cpu_limit: usize, @@ -341,16 +342,14 @@ pub struct Runtime { pub(crate) vacation_use_orig_rcpt: bool, pub(crate) vacation_default_subject: Cow<'static, str>, pub(crate) vacation_subject_prefix: Cow<'static, str>, - - pub(crate) context: C, } #[derive(Clone, Debug)] -pub struct Context<'x, C> { +pub struct Context<'x> { #[cfg(test)] - pub(crate) runtime: Runtime, + pub(crate) runtime: Runtime, #[cfg(not(test))] - pub(crate) runtime: &'x Runtime, + pub(crate) runtime: &'x Runtime, pub(crate) user_address: Cow<'x, str>, pub(crate) user_full_name: Cow<'x, str>, pub(crate) current_time: i64, diff --git a/src/runtime/actions/action_convert.rs b/src/runtime/actions/action_convert.rs index 76787ad..9d4e30f 100644 --- a/src/runtime/actions/action_convert.rs +++ b/src/runtime/actions/action_convert.rs @@ -38,7 +38,7 @@ enum Conversion { } impl Convert { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let _from_media_type = ctx.eval_value(&self.from_media_type); let _to_media_type = ctx.eval_value(&self.to_media_type); diff --git a/src/runtime/actions/action_editheader.rs b/src/runtime/actions/action_editheader.rs index e9e1e9e..4a2596f 100644 --- a/src/runtime/actions/action_editheader.rs +++ b/src/runtime/actions/action_editheader.rs @@ -37,7 +37,7 @@ use crate::{ }; impl AddHeader { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let header_name__ = ctx.eval_value(&self.field_name); let header_name_ = header_name__.to_string(); let mut header_name = String::with_capacity(header_name_.len()); @@ -68,7 +68,7 @@ impl AddHeader { } impl DeleteHeader { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let header_name__ = ctx.eval_value(&self.field_name); let header_name_ = header_name__.to_string(); let header_name = if let Some(header_name) = HeaderName::parse(header_name_.as_ref()) { @@ -171,7 +171,7 @@ impl RemoveCrLf for &str { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn insert_header( &mut self, part_id: usize, diff --git a/src/runtime/actions/action_fileinto.rs b/src/runtime/actions/action_fileinto.rs index 7d9d888..1db3f51 100644 --- a/src/runtime/actions/action_fileinto.rs +++ b/src/runtime/actions/action_fileinto.rs @@ -24,7 +24,7 @@ use crate::{compiler::grammar::actions::action_fileinto::FileInto, Context, Event}; impl FileInto { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let folder = ctx.eval_value(&self.folder).to_string().into_owned(); let mut events = Vec::with_capacity(2); if let Some(event) = ctx.build_message_id() { diff --git a/src/runtime/actions/action_flags.rs b/src/runtime/actions/action_flags.rs index 092c02f..fad2164 100644 --- a/src/runtime/actions/action_flags.rs +++ b/src/runtime/actions/action_flags.rs @@ -30,7 +30,7 @@ use crate::{ }; impl EditFlags { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let mut var_name_ = None; let var_name = self.name.as_ref().unwrap_or_else(|| { var_name_.get_or_insert_with(|| VariableType::Global("__flags".to_string())) @@ -103,7 +103,7 @@ impl EditFlags { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn tokenize_flags( &self, strings: &[Value], diff --git a/src/runtime/actions/action_include.rs b/src/runtime/actions/action_include.rs index bdf1a95..713cca7 100644 --- a/src/runtime/actions/action_include.rs +++ b/src/runtime/actions/action_include.rs @@ -37,7 +37,7 @@ pub(crate) enum IncludeResult { } impl Include { - pub(crate) fn exec(&self, ctx: &Context) -> IncludeResult { + pub(crate) fn exec(&self, ctx: &Context) -> IncludeResult { let script_name = ctx.eval_value(&self.value); if !script_name.is_empty() { let script_name = if self.location == Location::Global { diff --git a/src/runtime/actions/action_mime.rs b/src/runtime/actions/action_mime.rs index d7aa9a0..be6fc80 100644 --- a/src/runtime/actions/action_mime.rs +++ b/src/runtime/actions/action_mime.rs @@ -41,7 +41,7 @@ use super::action_editheader::RemoveCrLf; use mail_builder::headers::message_id::generate_message_id_header; impl Replace { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { // Delete children parts let mut part_ids = ctx.find_nested_parts_ids(false); part_ids.sort_unstable_by_key(|a| Reverse(*a)); @@ -182,7 +182,7 @@ impl Replace { } impl Enclose { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let body = ctx.eval_value(&self.value).to_string().into_owned(); let subject = self .subject @@ -341,7 +341,7 @@ impl Enclose { } impl ExtractText { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let mut value = String::new(); if !ctx.part_iter_stack.is_empty() { @@ -400,7 +400,7 @@ enum StackItem<'x> { None, } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn build_message_id(&mut self) -> Option { if self.has_changes { self.last_message_id += 1; diff --git a/src/runtime/actions/action_notify.rs b/src/runtime/actions/action_notify.rs index bfabb5b..3438057 100644 --- a/src/runtime/actions/action_notify.rs +++ b/src/runtime/actions/action_notify.rs @@ -35,7 +35,7 @@ use crate::{ use super::action_vacation::MAX_SUBJECT_LEN; impl Notify { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { // Do not notify on Auto-Submitted messages for header in &ctx.message.parts[0].headers { if matches!(&header.name, HeaderName::Other(name) if name.eq_ignore_ascii_case("Auto-Submitted")) diff --git a/src/runtime/actions/action_redirect.rs b/src/runtime/actions/action_redirect.rs index 15b57db..5b4599d 100644 --- a/src/runtime/actions/action_redirect.rs +++ b/src/runtime/actions/action_redirect.rs @@ -29,7 +29,7 @@ use crate::{ }; impl Redirect { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { if let Some(address) = sanitize_address(ctx.eval_value(&self.address).to_string().as_ref()) { if ctx.num_redirects < ctx.runtime.max_redirects diff --git a/src/runtime/actions/action_set.rs b/src/runtime/actions/action_set.rs index 78adb0d..7cce394 100644 --- a/src/runtime/actions/action_set.rs +++ b/src/runtime/actions/action_set.rs @@ -32,7 +32,7 @@ use crate::{ use std::fmt::Write; impl Set { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let mut value = ctx.eval_value(&self.value); for modifier in &self.modifiers { value = modifier.apply(value.to_string().as_ref(), ctx).into(); @@ -42,7 +42,7 @@ impl Set { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn set_variable(&mut self, var_name: &VariableType, mut variable: Variable) { if variable.len() > self.runtime.max_variable_size { let mut new_variable = String::with_capacity(self.runtime.max_variable_size); @@ -100,7 +100,7 @@ impl<'x, C> Context<'x, C> { } impl Modifier { - pub(crate) fn apply(&self, input: &str, ctx: &Context) -> String { + pub(crate) fn apply(&self, input: &str, ctx: &Context) -> String { let max_len = ctx.runtime.max_variable_size; match self { Modifier::Lower => input.to_lowercase(), diff --git a/src/runtime/actions/action_vacation.rs b/src/runtime/actions/action_vacation.rs index ed0edd6..a29d0e7 100644 --- a/src/runtime/actions/action_vacation.rs +++ b/src/runtime/actions/action_vacation.rs @@ -41,7 +41,7 @@ use crate::{ pub(crate) const MAX_SUBJECT_LEN: usize = 256; impl TestVacation { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let mut from = String::new(); let mut user_addresses = Vec::new(); @@ -177,7 +177,7 @@ impl TestVacation { } impl Vacation { - pub(crate) fn exec(&self, ctx: &mut Context) { + pub(crate) fn exec(&self, ctx: &mut Context) { let mut vacation_to = Cow::from(""); for (name, value) in &ctx.envelope { diff --git a/src/runtime/context.rs b/src/runtime/context.rs index 8d50220..0704cd5 100644 --- a/src/runtime/context.rs +++ b/src/runtime/context.rs @@ -46,9 +46,9 @@ pub(crate) struct ScriptStack { pub(crate) prev_vars_match: Vec, } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { #[cfg(not(test))] - pub(crate) fn new(runtime: &'x Runtime, message: Message<'x>) -> Self { + pub(crate) fn new(runtime: &'x Runtime, message: Message<'x>) -> Self { Context { #[cfg(test)] runtime: runtime.clone(), @@ -657,15 +657,11 @@ impl<'x, C> Context<'x, C> { pub fn part(&self) -> usize { self.part } - - pub fn context(&self) -> &C { - &self.runtime.context - } } #[cfg(test)] -impl<'x, C: Clone> Context<'x, C> { - pub(crate) fn new(runtime: &'x Runtime, message: Message<'x>) -> Self { +impl<'x> Context<'x> { + pub(crate) fn new(runtime: &'x Runtime, message: Message<'x>) -> Self { Context { runtime: runtime.clone(), message, diff --git a/src/runtime/eval.rs b/src/runtime/eval.rs index 328ef25..c8ae62a 100644 --- a/src/runtime/eval.rs +++ b/src/runtime/eval.rs @@ -39,7 +39,7 @@ use crate::{ use super::Variable; -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn variable<'y: 'x>(&'y self, var: &VariableType) -> Option { match var { VariableType::Local(var_num) => self.vars_local.get(*var_num).cloned(), diff --git a/src/runtime/expression.rs b/src/runtime/expression.rs index 1607ce6..8fad573 100644 --- a/src/runtime/expression.rs +++ b/src/runtime/expression.rs @@ -29,7 +29,7 @@ use crate::{compiler::Number, runtime::Variable, Context}; use crate::compiler::grammar::expr::{BinaryOperator, Constant, Expression, UnaryOperator}; -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn eval_expression(&mut self, expr: &[Expression]) -> Result { let mut exprs = expr.iter().skip(self.expr_pos); while let Some(expr) = exprs.next() { diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index 2ebbc61..a51a973 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -317,8 +317,8 @@ impl Hash for Variable { } #[cfg(not(test))] -impl Runtime { - pub fn filter<'z: 'x, 'x>(&'z self, raw_message: &'x [u8]) -> Context<'x, C> { +impl Runtime { + pub fn filter<'z: 'x, 'x>(&'z self, raw_message: &'x [u8]) -> Context<'x> { Context::new( self, MessageParser::new() @@ -339,25 +339,19 @@ impl Runtime { ) } - pub fn filter_parsed<'z: 'x, 'x>(&'z self, message: Message<'x>) -> Context<'x, C> { + pub fn filter_parsed<'z: 'x, 'x>(&'z self, message: Message<'x>) -> Context<'x> { Context::new(self, message) } } -impl Runtime<()> { - pub fn new() -> Runtime<()> { - Self::new_with_context(()) - } -} - -impl Default for Runtime<()> { +impl Default for Runtime { fn default() -> Self { Self::new() } } -impl Runtime { - pub fn new_with_context(context: C) -> Self { +impl Runtime { + pub fn new() -> Self { #[allow(unused_mut)] let mut allowed_capabilities = AHashSet::from_iter(Capability::all().iter().cloned()); @@ -392,7 +386,6 @@ impl Runtime { default_duplicate_expiry: 7 * 86400, local_hostname: "localhost".into(), functions: Vec::new(), - context, } } @@ -631,21 +624,17 @@ impl Runtime { self } - pub fn with_functions(mut self, fnc_map: &mut FunctionMap) -> Self { + pub fn with_functions(mut self, fnc_map: &mut FunctionMap) -> Self { self.functions = std::mem::take(&mut fnc_map.functions); self } - pub fn set_functions(&mut self, fnc_map: &mut FunctionMap) { + pub fn set_functions(&mut self, fnc_map: &mut FunctionMap) { self.functions = std::mem::take(&mut fnc_map.functions); } - - pub fn context(&self) -> &C { - &self.context - } } -impl FunctionMap { +impl FunctionMap { pub fn new() -> Self { FunctionMap { map: Default::default(), @@ -653,18 +642,18 @@ impl FunctionMap { } } - pub fn with_function(self, name: impl Into, fnc: Function) -> Self { + pub fn with_function(self, name: impl Into, fnc: Function) -> Self { self.with_function_args(name, fnc, 1) } - pub fn with_function_no_args(self, name: impl Into, fnc: Function) -> Self { + pub fn with_function_no_args(self, name: impl Into, fnc: Function) -> Self { self.with_function_args(name, fnc, 0) } pub fn with_function_args( mut self, name: impl Into, - fnc: Function, + fnc: Function, num_args: u32, ) -> Self { self.map diff --git a/src/runtime/tests/mime.rs b/src/runtime/tests/mime.rs index b06b011..71c76d3 100644 --- a/src/runtime/tests/mime.rs +++ b/src/runtime/tests/mime.rs @@ -33,15 +33,15 @@ pub(crate) enum ContentTypeFilter { TypeSubtype((String, String)), } -pub(crate) struct SubpartIterator<'x, C> { - ctx: &'x Context<'x, C>, +pub(crate) struct SubpartIterator<'x> { + ctx: &'x Context<'x>, iter: Iter<'x, usize>, iter_stack: Vec>, anychild: bool, } -impl<'x, C> SubpartIterator<'x, C> { - pub(crate) fn new(ctx: &'x Context<'x, C>, parts: &'x [usize], anychild: bool) -> Self { +impl<'x> SubpartIterator<'x> { + pub(crate) fn new(ctx: &'x Context<'x>, parts: &'x [usize], anychild: bool) -> Self { SubpartIterator { ctx, iter: parts.iter(), @@ -73,7 +73,7 @@ impl<'x, C> SubpartIterator<'x, C> { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn find_nested_parts<'z: 'x>( &'z self, mut message: &'x Message<'x>, diff --git a/src/runtime/tests/mod.rs b/src/runtime/tests/mod.rs index 2042ce5..4524648 100644 --- a/src/runtime/tests/mod.rs +++ b/src/runtime/tests/mod.rs @@ -53,7 +53,7 @@ pub(crate) enum TestResult { } impl Test { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { match &self { Test::Header(test) => test.exec(ctx), Test::Address(test) => test.exec(ctx), diff --git a/src/runtime/tests/test_address.rs b/src/runtime/tests/test_address.rs index e0a660d..d94f934 100644 --- a/src/runtime/tests/test_address.rs +++ b/src/runtime/tests/test_address.rs @@ -43,7 +43,7 @@ use crate::{ use super::TestResult; impl TestAddress { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let key_list = ctx.eval_values(&self.key_list); let header_list = ctx.parse_header_names(&self.header_list); @@ -186,7 +186,7 @@ impl TestAddress { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { #[allow(unused_assignments)] pub(crate) fn find_addresses( &self, diff --git a/src/runtime/tests/test_body.rs b/src/runtime/tests/test_body.rs index 331ea90..42dfdfc 100644 --- a/src/runtime/tests/test_body.rs +++ b/src/runtime/tests/test_body.rs @@ -37,7 +37,7 @@ use crate::{ use super::{mime::ContentTypeFilter, TestResult}; impl TestBody { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { // Check Subject (not a Sieve standard) let key_list = ctx.eval_values(&self.key_list); if self.include_subject { diff --git a/src/runtime/tests/test_date.rs b/src/runtime/tests/test_date.rs index 0c2fdbc..5789bb8 100644 --- a/src/runtime/tests/test_date.rs +++ b/src/runtime/tests/test_date.rs @@ -39,7 +39,7 @@ use crate::{ use super::TestResult; impl TestDate { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let header_name = if let Some(header_name) = ctx.parse_header_name(&self.header_name) { header_name } else { @@ -158,7 +158,7 @@ impl TestDate { } impl TestCurrentDate { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let mut result = false; match &self.match_type { @@ -240,7 +240,7 @@ impl TestCurrentDate { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { #[allow(unused_assignments)] pub(crate) fn find_dates(&self, header: &'x Header) -> Option> { if let HeaderValue::DateTime(dt) = &header.value { diff --git a/src/runtime/tests/test_duplicate.rs b/src/runtime/tests/test_duplicate.rs index bf52fcf..f188ee5 100644 --- a/src/runtime/tests/test_duplicate.rs +++ b/src/runtime/tests/test_duplicate.rs @@ -33,7 +33,7 @@ use crate::{ use super::TestResult; impl TestDuplicate { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let id: Cow = match &self.dup_match { DupMatch::Header(header_name) => { let mut value = String::new(); diff --git a/src/runtime/tests/test_envelope.rs b/src/runtime/tests/test_envelope.rs index f990e41..9739c37 100644 --- a/src/runtime/tests/test_envelope.rs +++ b/src/runtime/tests/test_envelope.rs @@ -34,7 +34,7 @@ use crate::{ use super::TestResult; impl TestEnvelope { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let key_list = ctx.eval_values(&self.key_list); let result = match &self.match_type { @@ -149,7 +149,7 @@ impl TestEnvelope { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { fn find_envelopes( &self, test_envelope: &TestEnvelope, diff --git a/src/runtime/tests/test_exists.rs b/src/runtime/tests/test_exists.rs index 43e49b6..afea66a 100644 --- a/src/runtime/tests/test_exists.rs +++ b/src/runtime/tests/test_exists.rs @@ -26,7 +26,7 @@ use crate::{compiler::grammar::tests::test_exists::TestExists, Context}; use super::{mime::SubpartIterator, TestResult}; impl TestExists { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let header_names = ctx.parse_header_names(&self.header_names); let mut header_exists = vec![false; header_names.len()]; let parts = [ctx.part]; diff --git a/src/runtime/tests/test_extlists.rs b/src/runtime/tests/test_extlists.rs index a396f30..458086b 100644 --- a/src/runtime/tests/test_extlists.rs +++ b/src/runtime/tests/test_extlists.rs @@ -26,7 +26,7 @@ use crate::{compiler::grammar::tests::test_extlists::TestValidExtList, Context}; use super::TestResult; impl TestValidExtList { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let mut num_valid = 0; for list in &self.list_names { diff --git a/src/runtime/tests/test_hasflag.rs b/src/runtime/tests/test_hasflag.rs index d597ea5..6957d4e 100644 --- a/src/runtime/tests/test_hasflag.rs +++ b/src/runtime/tests/test_hasflag.rs @@ -32,7 +32,7 @@ use crate::{ use super::TestResult; impl TestHasFlag { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let mut variable_list_ = None; let variable_list = if !self.variable_list.is_empty() { &self.variable_list diff --git a/src/runtime/tests/test_header.rs b/src/runtime/tests/test_header.rs index a1c805c..57f6490 100644 --- a/src/runtime/tests/test_header.rs +++ b/src/runtime/tests/test_header.rs @@ -35,7 +35,7 @@ use crate::{ use super::{mime::SubpartIterator, TestResult}; impl TestHeader { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let key_list = ctx.eval_values(&self.key_list); let header_list = ctx.parse_header_names(&self.header_list); let mime_opts = match &self.mime_opts { @@ -203,7 +203,7 @@ impl TestHeader { } } -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn parse_header_names<'z: 'y, 'y>( &'z self, header_names: &'y [Value], diff --git a/src/runtime/tests/test_metadata.rs b/src/runtime/tests/test_metadata.rs index 4526a23..4d3fa54 100644 --- a/src/runtime/tests/test_metadata.rs +++ b/src/runtime/tests/test_metadata.rs @@ -35,7 +35,7 @@ use crate::{ use super::TestResult; impl TestMetadata { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let metadata = match &self.medatata { Metadata::Server { annotation } => Metadata::Server { annotation: ctx.eval_value(annotation).to_string().into_owned(), @@ -122,7 +122,7 @@ impl TestMetadata { } impl TestMetadataExists { - pub(crate) fn exec(&self, ctx: &Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &Context) -> TestResult { let mailbox = self .mailbox .as_ref() diff --git a/src/runtime/tests/test_notify.rs b/src/runtime/tests/test_notify.rs index acb2434..135c917 100644 --- a/src/runtime/tests/test_notify.rs +++ b/src/runtime/tests/test_notify.rs @@ -38,7 +38,7 @@ use crate::{ use super::TestResult; impl TestValidNotifyMethod { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let mut num_valid = 0; for uri in &self.notification_uris { @@ -61,7 +61,7 @@ impl TestValidNotifyMethod { } impl TestNotifyMethodCapability { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let uri_ = ctx.eval_value(&self.notification_uri); let uri = uri_.to_string(); if !ctx diff --git a/src/runtime/tests/test_size.rs b/src/runtime/tests/test_size.rs index aff5068..bf521b2 100644 --- a/src/runtime/tests/test_size.rs +++ b/src/runtime/tests/test_size.rs @@ -26,7 +26,7 @@ use crate::{compiler::grammar::tests::test_size::TestSize, Context}; use super::TestResult; impl TestSize { - pub(crate) fn exec(&self, ctx: &Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &Context) -> TestResult { TestResult::Bool( (if self.over { ctx.message_size > self.limit diff --git a/src/runtime/tests/test_spamtest.rs b/src/runtime/tests/test_spamtest.rs index c8214b2..6d13b5b 100644 --- a/src/runtime/tests/test_spamtest.rs +++ b/src/runtime/tests/test_spamtest.rs @@ -36,7 +36,7 @@ use crate::{ use super::TestResult; impl TestSpamTest { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let status = if self.percent { ctx.spam_status.as_percentage() } else { @@ -84,7 +84,7 @@ impl TestSpamTest { } impl TestVirusTest { - pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult { let status = ctx.virus_status.as_number(); let value = ctx.eval_value(&self.value); let mut captured_values = Vec::new(); diff --git a/src/runtime/tests/test_string.rs b/src/runtime/tests/test_string.rs index b2e74b8..b8152d3 100644 --- a/src/runtime/tests/test_string.rs +++ b/src/runtime/tests/test_string.rs @@ -32,7 +32,7 @@ use crate::{ use super::TestResult; impl TestString { - pub(crate) fn exec(&self, ctx: &mut Context, empty_is_null: bool) -> TestResult { + pub(crate) fn exec(&self, ctx: &mut Context, empty_is_null: bool) -> TestResult { let mut result = false; match &self.match_type { diff --git a/src/runtime/variables.rs b/src/runtime/variables.rs index d46134c..b2481df 100644 --- a/src/runtime/variables.rs +++ b/src/runtime/variables.rs @@ -25,7 +25,7 @@ use crate::Context; use super::Variable; -impl<'x, C> Context<'x, C> { +impl<'x> Context<'x> { pub(crate) fn set_match_variables(&mut self, set_vars: Vec<(usize, String)>) { for (var_num, value) in set_vars { if let Some(var) = self.vars_match.get_mut(var_num) {