Skip to main content

Crate mailrs_sieve_core

Crate mailrs_sieve_core 

Source
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 envelope test 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.
VacationAction
RFC 5230 vacation action — 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.
EvalError
Eval failure modes.
MatchType
Standardised match-type for the evaluator.
ParseError
Parse failure modes.
Token
One lexeme. String and Number carry the parsed value; Identifier and Tag carry the slice content.
TokenizeError
Lex failure mode.
VacationParseError
Failure modes when parsing a vacation command’s argument list.
VacationPeriod
The :days / :seconds window on a vacation action.

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 envelope test inspects from / to / auth.
parse_script
Tokenize + parse a full Sieve script.
parse_vacation_args
Parse the argument vector of a vacation command into a VacationAction. Caller passes cmd.args from 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 every require declares a supported capability.