Expand description
Native RFC 5228 Sieve interpreter.
The internal engine mailrs-sieve (the wrapper) will route to
once it reaches differential parity with sieve-rs (v8 ckpt 6
swap). This crate is Apache-2.0 OR MIT — no AGPL, no
deny.toml exception.
§Quick start
use mailrs_sieve_core::{Action, eval_script};
let script = r#"
require ["fileinto"];
if header :is "Subject" "spam" {
fileinto "Junk";
} else {
keep;
}
"#;
let message = b"Subject: spam\r\n\r\nbody\r\n";
let actions = eval_script(script, message).unwrap();
assert_eq!(
actions,
vec![Action::FileInto { mailbox: "Junk".into(), flags: vec![] }],
);§Status
0.1 — RFC 5228 base + RFC 5230 vacation + RFC 5232 imap4flags.
See CHANGELOG.md.
Structs§
- Command
- One Sieve command — identifier + args + optional nested block.
- Envelope
- RFC 5228 §5.4 envelope context — caller-supplied state the
envelopetest inspects. - Test
- One test expression. The match-types + address-parts get extracted into the dedicated fields so the evaluator doesn’t scan the arg list every time.
- Vacation
Action - RFC 5230
vacationaction — everything the caller needs to generate the auto-reply.
Enums§
- Action
- One action the evaluator emits.
- Argument
- Argument to a command or a nested test.
- Eval
Error - Eval failure modes.
- Match
Type - Standardised match-type for the evaluator.
- Parse
Error - Parse failure modes.
- Token
- One lexeme.
StringandNumbercarry the parsed value;IdentifierandTagcarry the slice content. - Tokenize
Error - Lex failure mode.
- Vacation
Parse Error - Failure modes when parsing a
vacationcommand’s argument list. - Vacation
Period - The
:days/:secondswindow on avacationaction.
Functions§
- eval_
script - Evaluate a Sieve script against a message. Returns the
action list the delivery layer should apply, or
[Keep]if no script action fired (the RFC 5228 §2.10.6 implicit keep). - eval_
script_ with_ envelope - Evaluate a Sieve script with an explicit SMTP envelope. The
RFC 5228 §5.4
envelopetest inspectsfrom/to/auth. - parse_
script - Tokenize + parse a full Sieve script.
- parse_
vacation_ args - Parse the argument vector of a
vacationcommand into aVacationAction. Caller passescmd.argsfrom the AST. - tokenize
- Tokenize a Sieve source string. Returns the token sequence without any positional metadata — parser line/column tracking is a v0.2 nicety.
- validate
- Validate that every extension used is
required and everyrequiredeclares a supported capability.