pub struct ParserOptions { /* private fields */ }Expand description
Caller-provided configuration for the parser.
§Custom filters
The built-in filter vocabulary (is:unread, has:attachment, etc.)
is fixed at compile time. Anything else — is:owed-reply,
has:reaction, is:my-app-flag — returns
ParseError::UnknownFilter by
default. Register the names you want to accept so they parse as
FilterKind::Custom instead.
use mail_query::{parse_with, FilterKind, ParserOptions, QueryNode};
let mut options = ParserOptions::default();
options.register_custom_filter("owed-reply");
let ast = parse_with("is:owed-reply", &options).expect("parses");
assert_eq!(
ast,
QueryNode::Filter(FilterKind::Custom("owed-reply".into()))
);Implementations§
Source§impl ParserOptions
impl ParserOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
New empty options. Equivalent to Default::default.
Sourcepub fn register_custom_filter(&mut self, name: impl Into<String>) -> &mut Self
pub fn register_custom_filter(&mut self, name: impl Into<String>) -> &mut Self
Register a custom filter name. The crate canonicalises to
lowercase + hyphenated form (Reply_Later becomes reply-later),
so callers can pass any casing.
Sourcepub fn register_custom_filters<I, S>(&mut self, names: I) -> &mut Self
pub fn register_custom_filters<I, S>(&mut self, names: I) -> &mut Self
Register many custom filter names at once.
Trait Implementations§
Source§impl Debug for ParserOptions
impl Debug for ParserOptions
Source§impl Default for ParserOptions
impl Default for ParserOptions
Source§fn default() -> ParserOptions
fn default() -> ParserOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ParserOptions
impl RefUnwindSafe for ParserOptions
impl Send for ParserOptions
impl Sync for ParserOptions
impl Unpin for ParserOptions
impl UnsafeUnpin for ParserOptions
impl UnwindSafe for ParserOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more