Skip to main content

mailrs_sieve_core/
lib.rs

1#![deny(missing_docs)]
2#![deny(rustdoc::broken_intra_doc_links)]
3
4//! Native RFC 5228 Sieve interpreter.
5//!
6//! The internal engine `mailrs-sieve` (the wrapper) will route to
7//! once it reaches differential parity with `sieve-rs` (v8 ckpt 6
8//! swap). This crate is Apache-2.0 OR MIT — no AGPL, no
9//! `deny.toml` exception.
10//!
11//! ## Quick start
12//!
13//! ```
14//! use mailrs_sieve_core::{Action, eval_script};
15//!
16//! let script = r#"
17//!     require ["fileinto"];
18//!     if header :is "Subject" "spam" {
19//!         fileinto "Junk";
20//!     } else {
21//!         keep;
22//!     }
23//! "#;
24//! let message = b"Subject: spam\r\n\r\nbody\r\n";
25//! let actions = eval_script(script, message).unwrap();
26//! assert_eq!(
27//!     actions,
28//!     vec![Action::FileInto { mailbox: "Junk".into(), flags: vec![] }],
29//! );
30//! ```
31//!
32//! ## Status
33//!
34//! 0.1 — RFC 5228 base + RFC 5230 vacation + RFC 5232 imap4flags.
35//! See `CHANGELOG.md`.
36
37mod address;
38mod ast;
39mod capabilities;
40mod eval;
41mod lex;
42mod match_str;
43mod parse;
44mod vacation;
45
46pub use ast::{
47    Action, Argument, Command, Envelope, MatchType, Test, VacationAction, VacationPeriod,
48};
49pub use capabilities::validate;
50pub use eval::{EvalError, eval_script, eval_script_with_envelope};
51pub use lex::{Token, TokenizeError, tokenize};
52pub use parse::{ParseError, parse_script};
53pub use vacation::{VacationParseError, parse_vacation_args};