Skip to main content

whichtime_sys/parsers/
mod.rs

1//! Parser infrastructure and locale-specific implementations.
2//!
3//! Parsers are responsible for identifying date expressions in text and
4//! turning them into [`ParsedResult`] values before refiners run.
5
6pub mod common;
7pub mod de;
8pub mod en;
9pub mod es;
10pub mod fr;
11pub mod it;
12pub mod ja;
13pub mod nl;
14pub mod pt;
15pub mod ru;
16pub mod sv;
17pub mod uk;
18pub mod zh;
19
20use crate::context::ParsingContext;
21use crate::error::Result;
22use crate::results::ParsedResult;
23
24/// Trait implemented by individual date/time parsers.
25pub trait Parser: Send + Sync {
26    /// Get a name for this parser (for debugging)
27    fn name(&self) -> &'static str;
28
29    /// Check if this parser should run on the given context
30    /// This is a fast pre-filter to skip parsers that won't match
31    fn should_apply(&self, context: &ParsingContext) -> bool;
32
33    /// Parse the text and return all matches
34    fn parse(&self, context: &ParsingContext) -> Result<Vec<ParsedResult>>;
35}