Skip to content

Commit 45688a8

Browse files
committed
v0.5.0
1 parent 5e265aa commit 45688a8

36 files changed

+83
-105
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"rust-analyzer.showUnlinkedFileNotification": false
3+
}

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
sieve-rs 0.5.0
2+
================================
3+
- Removed context.
4+
15
sieve-rs 0.4.0
26
================================
37
- Support for expressions.

src/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl Compiler {
330330
self
331331
}
332332

333-
pub fn register_functions<C>(mut self, fnc_map: &mut FunctionMap<C>) -> Self {
333+
pub fn register_functions(mut self, fnc_map: &mut FunctionMap) -> Self {
334334
self.functions = std::mem::take(&mut fnc_map.map);
335335
self
336336
}

src/lib.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ pub struct Sieve {
289289
num_match_vars: usize,
290290
}
291291

292+
#[derive(Clone)]
292293
pub struct Compiler {
293294
// Settings
294295
pub(crate) max_script_size: usize,
@@ -307,16 +308,16 @@ pub struct Compiler {
307308
pub(crate) functions: AHashMap<String, (u32, u32)>,
308309
}
309310

310-
pub type Function<C> = for<'x> fn(&'x Context<'x, C>, Vec<Variable>) -> Variable;
311+
pub type Function = for<'x> fn(&'x Context<'x>, Vec<Variable>) -> Variable;
311312

312313
#[derive(Default, Clone)]
313-
pub struct FunctionMap<C> {
314+
pub struct FunctionMap {
314315
pub(crate) map: AHashMap<String, (u32, u32)>,
315-
pub(crate) functions: Vec<Function<C>>,
316+
pub(crate) functions: Vec<Function>,
316317
}
317318

318319
#[derive(Debug, Clone)]
319-
pub struct Runtime<C> {
320+
pub struct Runtime {
320321
pub(crate) allowed_capabilities: AHashSet<Capability>,
321322
pub(crate) valid_notification_uris: AHashSet<Cow<'static, str>>,
322323
pub(crate) valid_ext_lists: AHashSet<Cow<'static, str>>,
@@ -325,7 +326,7 @@ pub struct Runtime<C> {
325326
pub(crate) metadata: Vec<(Metadata<String>, Cow<'static, str>)>,
326327
pub(crate) include_scripts: AHashMap<String, Arc<Sieve>>,
327328
pub(crate) local_hostname: Cow<'static, str>,
328-
pub(crate) functions: Vec<Function<C>>,
329+
pub(crate) functions: Vec<Function>,
329330

330331
pub(crate) max_nested_includes: usize,
331332
pub(crate) cpu_limit: usize,
@@ -341,16 +342,14 @@ pub struct Runtime<C> {
341342
pub(crate) vacation_use_orig_rcpt: bool,
342343
pub(crate) vacation_default_subject: Cow<'static, str>,
343344
pub(crate) vacation_subject_prefix: Cow<'static, str>,
344-
345-
pub(crate) context: C,
346345
}
347346

348347
#[derive(Clone, Debug)]
349-
pub struct Context<'x, C> {
348+
pub struct Context<'x> {
350349
#[cfg(test)]
351-
pub(crate) runtime: Runtime<C>,
350+
pub(crate) runtime: Runtime,
352351
#[cfg(not(test))]
353-
pub(crate) runtime: &'x Runtime<C>,
352+
pub(crate) runtime: &'x Runtime,
354353
pub(crate) user_address: Cow<'x, str>,
355354
pub(crate) user_full_name: Cow<'x, str>,
356355
pub(crate) current_time: i64,

src/runtime/actions/action_convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum Conversion {
3838
}
3939

4040
impl Convert {
41-
pub(crate) fn exec<C>(&self, ctx: &mut Context<C>) -> TestResult {
41+
pub(crate) fn exec(&self, ctx: &mut Context) -> TestResult {
4242
let _from_media_type = ctx.eval_value(&self.from_media_type);
4343
let _to_media_type = ctx.eval_value(&self.to_media_type);
4444

src/runtime/actions/action_editheader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::{
3737
};
3838

3939
impl AddHeader {
40-
pub(crate) fn exec<C>(&self, ctx: &mut Context<C>) {
40+
pub(crate) fn exec(&self, ctx: &mut Context) {
4141
let header_name__ = ctx.eval_value(&self.field_name);
4242
let header_name_ = header_name__.to_string();
4343
let mut header_name = String::with_capacity(header_name_.len());
@@ -68,7 +68,7 @@ impl AddHeader {
6868
}
6969

7070
impl DeleteHeader {
71-
pub(crate) fn exec<C>(&self, ctx: &mut Context<C>) {
71+
pub(crate) fn exec(&self, ctx: &mut Context) {
7272
let header_name__ = ctx.eval_value(&self.field_name);
7373
let header_name_ = header_name__.to_string();
7474
let header_name = if let Some(header_name) = HeaderName::parse(header_name_.as_ref()) {
@@ -171,7 +171,7 @@ impl RemoveCrLf for &str {
171171
}
172172
}
173173

174-
impl<'x, C> Context<'x, C> {
174+
impl<'x> Context<'x> {
175175
pub(crate) fn insert_header(
176176
&mut self,
177177
part_id: usize,

src/runtime/actions/action_fileinto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use crate::{compiler::grammar::actions::action_fileinto::FileInto, Context, Event};
2525

2626
impl FileInto {
27-
pub(crate) fn exec<C>(&self, ctx: &mut Context<C>) {
27+
pub(crate) fn exec(&self, ctx: &mut Context) {
2828
let folder = ctx.eval_value(&self.folder).to_string().into_owned();
2929
let mut events = Vec::with_capacity(2);
3030
if let Some(event) = ctx.build_message_id() {

src/runtime/actions/action_flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::{
3030
};
3131

3232
impl EditFlags {
33-
pub(crate) fn exec<C>(&self, ctx: &mut Context<C>) {
33+
pub(crate) fn exec(&self, ctx: &mut Context) {
3434
let mut var_name_ = None;
3535
let var_name = self.name.as_ref().unwrap_or_else(|| {
3636
var_name_.get_or_insert_with(|| VariableType::Global("__flags".to_string()))
@@ -103,7 +103,7 @@ impl EditFlags {
103103
}
104104
}
105105

106-
impl<'x, C> Context<'x, C> {
106+
impl<'x> Context<'x> {
107107
pub(crate) fn tokenize_flags(
108108
&self,
109109
strings: &[Value],

src/runtime/actions/action_include.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(crate) enum IncludeResult {
3737
}
3838

3939
impl Include {
40-
pub(crate) fn exec<C>(&self, ctx: &Context<C>) -> IncludeResult {
40+
pub(crate) fn exec(&self, ctx: &Context) -> IncludeResult {
4141
let script_name = ctx.eval_value(&self.value);
4242
if !script_name.is_empty() {
4343
let script_name = if self.location == Location::Global {

0 commit comments

Comments
 (0)