From cbd5a81a05453d76394f4f376ab1c3209dcf0204 Mon Sep 17 00:00:00 2001 From: Sven Sauleau Date: Fri, 26 Apr 2024 11:15:43 +0200 Subject: [PATCH] Mark some compiler structs as public Refs https://github.com/stalwartlabs/sieve/issues/3 --- src/compiler/grammar/actions/action_editheader.rs | 4 ++-- src/compiler/grammar/actions/action_fileinto.rs | 2 +- src/compiler/grammar/actions/action_keep.rs | 2 +- src/compiler/grammar/actions/action_mime.rs | 2 +- src/compiler/grammar/actions/action_redirect.rs | 2 +- src/compiler/grammar/actions/action_reject.rs | 2 +- src/compiler/grammar/actions/action_set.rs | 4 ++-- src/compiler/grammar/actions/action_vacation.rs | 6 +++--- src/compiler/grammar/instruction.rs | 2 +- src/compiler/grammar/mod.rs | 8 ++++---- src/compiler/grammar/test.rs | 2 +- src/compiler/grammar/tests/test_address.rs | 2 +- src/compiler/grammar/tests/test_body.rs | 4 ++-- src/compiler/grammar/tests/test_header.rs | 2 +- src/compiler/grammar/tests/test_ihave.rs | 2 +- src/compiler/grammar/tests/test_spamtest.rs | 2 +- src/compiler/grammar/tests/test_string.rs | 2 +- src/compiler/mod.rs | 2 +- src/lib.rs | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/compiler/grammar/actions/action_editheader.rs b/src/compiler/grammar/actions/action_editheader.rs index bc1d864..4569526 100644 --- a/src/compiler/grammar/actions/action_editheader.rs +++ b/src/compiler/grammar/actions/action_editheader.rs @@ -36,7 +36,7 @@ use crate::compiler::{ use crate::compiler::grammar::MatchType; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct AddHeader { +pub struct AddHeader { pub last: bool, pub field_name: Value, pub value: Value, @@ -50,7 +50,7 @@ pub(crate) struct AddHeader { */ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct DeleteHeader { +pub struct DeleteHeader { pub index: Option, pub comparator: Comparator, pub match_type: MatchType, diff --git a/src/compiler/grammar/actions/action_fileinto.rs b/src/compiler/grammar/actions/action_fileinto.rs index 6569f84..6beaa29 100644 --- a/src/compiler/grammar/actions/action_fileinto.rs +++ b/src/compiler/grammar/actions/action_fileinto.rs @@ -33,7 +33,7 @@ use crate::compiler::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct FileInto { +pub struct FileInto { pub copy: bool, pub create: bool, pub folder: Value, diff --git a/src/compiler/grammar/actions/action_keep.rs b/src/compiler/grammar/actions/action_keep.rs index f215bea..0e0fea0 100644 --- a/src/compiler/grammar/actions/action_keep.rs +++ b/src/compiler/grammar/actions/action_keep.rs @@ -33,7 +33,7 @@ use crate::compiler::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct Keep { +pub struct Keep { pub flags: Vec, } diff --git a/src/compiler/grammar/actions/action_mime.rs b/src/compiler/grammar/actions/action_mime.rs index 42bba8a..94f74fc 100644 --- a/src/compiler/grammar/actions/action_mime.rs +++ b/src/compiler/grammar/actions/action_mime.rs @@ -59,7 +59,7 @@ pub(crate) struct ExtractText { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum MimeOpts { +pub enum MimeOpts { Type, Subtype, ContentType, diff --git a/src/compiler/grammar/actions/action_redirect.rs b/src/compiler/grammar/actions/action_redirect.rs index 408038d..f04c1eb 100644 --- a/src/compiler/grammar/actions/action_redirect.rs +++ b/src/compiler/grammar/actions/action_redirect.rs @@ -33,7 +33,7 @@ use crate::compiler::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct Redirect { +pub struct Redirect { pub copy: bool, pub address: Value, pub notify: Notify, diff --git a/src/compiler/grammar/actions/action_reject.rs b/src/compiler/grammar/actions/action_reject.rs index 2893721..a367110 100644 --- a/src/compiler/grammar/actions/action_reject.rs +++ b/src/compiler/grammar/actions/action_reject.rs @@ -29,7 +29,7 @@ use crate::compiler::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct Reject { +pub struct Reject { pub ereject: bool, pub reason: Value, } diff --git a/src/compiler/grammar/actions/action_set.rs b/src/compiler/grammar/actions/action_set.rs index 1377c4e..874a3b2 100644 --- a/src/compiler/grammar/actions/action_set.rs +++ b/src/compiler/grammar/actions/action_set.rs @@ -36,7 +36,7 @@ use crate::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum Modifier { +pub enum Modifier { Lower, Upper, LowerFirst, @@ -65,7 +65,7 @@ impl Modifier { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct Set { +pub struct Set { pub modifiers: Vec, pub name: VariableType, pub value: Value, diff --git a/src/compiler/grammar/actions/action_vacation.rs b/src/compiler/grammar/actions/action_vacation.rs index f33ab21..9593abb 100644 --- a/src/compiler/grammar/actions/action_vacation.rs +++ b/src/compiler/grammar/actions/action_vacation.rs @@ -37,7 +37,7 @@ use crate::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct Vacation { +pub struct Vacation { pub subject: Option, pub from: Option, pub mime: bool, @@ -46,7 +46,7 @@ pub(crate) struct Vacation { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct TestVacation { +pub struct TestVacation { pub addresses: Vec, pub period: Period, pub handle: Option, @@ -54,7 +54,7 @@ pub(crate) struct TestVacation { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum Period { +pub enum Period { Days(u64), Seconds(u64), Default, diff --git a/src/compiler/grammar/instruction.rs b/src/compiler/grammar/instruction.rs index cf3dedc..927eddc 100644 --- a/src/compiler/grammar/instruction.rs +++ b/src/compiler/grammar/instruction.rs @@ -55,7 +55,7 @@ use super::{ use super::tests::test_ihave::Error; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] -pub(crate) enum Instruction { +pub enum Instruction { Require(Vec), Keep(Keep), FileInto(FileInto), diff --git a/src/compiler/grammar/mod.rs b/src/compiler/grammar/mod.rs index e5377dc..42dbf74 100644 --- a/src/compiler/grammar/mod.rs +++ b/src/compiler/grammar/mod.rs @@ -103,7 +103,7 @@ pub enum AddressPart { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum MatchType { +pub enum MatchType { Is, Contains, Matches(u64), @@ -134,9 +134,9 @@ pub enum Comparator { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Clear { - pub(crate) local_vars_idx: u32, - pub(crate) local_vars_num: u32, - pub(crate) match_vars: u64, + pub local_vars_idx: u32, + pub local_vars_num: u32, + pub match_vars: u64, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/src/compiler/grammar/test.rs b/src/compiler/grammar/test.rs index aa2175f..0f423e1 100644 --- a/src/compiler/grammar/test.rs +++ b/src/compiler/grammar/test.rs @@ -56,7 +56,7 @@ use super::{ #[allow(clippy::enum_variant_names)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum Test { +pub enum Test { True, False, Address(TestAddress), diff --git a/src/compiler/grammar/tests/test_address.rs b/src/compiler/grammar/tests/test_address.rs index 8bf88f4..146336e 100644 --- a/src/compiler/grammar/tests/test_address.rs +++ b/src/compiler/grammar/tests/test_address.rs @@ -32,7 +32,7 @@ use crate::compiler::{ use crate::compiler::grammar::{AddressPart, MatchType}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct TestAddress { +pub struct TestAddress { pub header_list: Vec, pub key_list: Vec, pub address_part: AddressPart, diff --git a/src/compiler/grammar/tests/test_body.rs b/src/compiler/grammar/tests/test_body.rs index 143c719..c169422 100644 --- a/src/compiler/grammar/tests/test_body.rs +++ b/src/compiler/grammar/tests/test_body.rs @@ -32,7 +32,7 @@ use crate::compiler::{ use crate::compiler::grammar::{test::Test, MatchType}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct TestBody { +pub struct TestBody { pub key_list: Vec, pub body_transform: BodyTransform, pub match_type: MatchType, @@ -42,7 +42,7 @@ pub(crate) struct TestBody { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum BodyTransform { +pub enum BodyTransform { Raw, Content(Vec), Text, diff --git a/src/compiler/grammar/tests/test_header.rs b/src/compiler/grammar/tests/test_header.rs index 35776cb..dfbba9b 100644 --- a/src/compiler/grammar/tests/test_header.rs +++ b/src/compiler/grammar/tests/test_header.rs @@ -37,7 +37,7 @@ use crate::compiler::{ use crate::compiler::grammar::{test::Test, MatchType}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct TestHeader { +pub struct TestHeader { pub header_list: Vec, pub key_list: Vec, pub match_type: MatchType, diff --git a/src/compiler/grammar/tests/test_ihave.rs b/src/compiler/grammar/tests/test_ihave.rs index 376c44b..02f14a7 100644 --- a/src/compiler/grammar/tests/test_ihave.rs +++ b/src/compiler/grammar/tests/test_ihave.rs @@ -37,7 +37,7 @@ pub(crate) struct TestIhave { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct Error { +pub struct Error { pub message: Value, } diff --git a/src/compiler/grammar/tests/test_spamtest.rs b/src/compiler/grammar/tests/test_spamtest.rs index 0a44448..0b6050c 100644 --- a/src/compiler/grammar/tests/test_spamtest.rs +++ b/src/compiler/grammar/tests/test_spamtest.rs @@ -37,7 +37,7 @@ use crate::compiler::grammar::{test::Test, MatchType}; */ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct TestSpamTest { +pub struct TestSpamTest { pub value: Value, pub match_type: MatchType, pub comparator: Comparator, diff --git a/src/compiler/grammar/tests/test_string.rs b/src/compiler/grammar/tests/test_string.rs index 71af20b..33defc2 100644 --- a/src/compiler/grammar/tests/test_string.rs +++ b/src/compiler/grammar/tests/test_string.rs @@ -32,7 +32,7 @@ use crate::compiler::{ use crate::compiler::grammar::{test::Test, MatchType}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) struct TestString { +pub struct TestString { pub match_type: MatchType, pub comparator: Comparator, pub source: Vec, diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index 18fd567..fec68ad 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -95,7 +95,7 @@ impl Default for Compiler { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub(crate) enum Value { +pub enum Value { Text(Arc), Number(Number), Variable(VariableType), diff --git a/src/lib.rs b/src/lib.rs index fca33e5..91e39a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -284,7 +284,7 @@ pub(crate) const MAX_LOCAL_VARIABLES: usize = 256; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct Sieve { - instructions: Vec, + pub instructions: Vec, num_vars: usize, num_match_vars: usize, }