pub struct ParsingContext<'a> {
pub text: &'a str,
pub reference: &'a ReferenceWithTimezone,
pub tokens: Vec<Token>,
pub locale: Locale,
/* private fields */
}Expand description
Shared state for a single parse request.
Parsers and refiners receive a ParsingContext so they can reuse the input
text, reference time, locale, and precomputed token scan.
Fields§
§text: &'a strOriginal input text.
reference: &'a ReferenceWithTimezoneReference date/time used to resolve relative expressions.
tokens: Vec<Token>Tokens discovered during the scanner pre-pass.
locale: LocaleActive locale for the parse request.
Implementations§
Source§impl<'a> ParsingContext<'a>
impl<'a> ParsingContext<'a>
Sourcepub fn new(text: &'a str, reference: &'a ReferenceWithTimezone) -> Self
pub fn new(text: &'a str, reference: &'a ReferenceWithTimezone) -> Self
Create a new English parsing context.
Sourcepub fn with_locale(
text: &'a str,
reference: &'a ReferenceWithTimezone,
locale: Locale,
) -> Self
pub fn with_locale( text: &'a str, reference: &'a ReferenceWithTimezone, locale: Locale, ) -> Self
Create a parsing context for a specific locale.
Sourcepub fn lower_text(&self) -> &str
pub fn lower_text(&self) -> &str
Return the cached lowercase representation of the input.
Sourcepub fn create_components(&self) -> FastComponents
pub fn create_components(&self) -> FastComponents
Create a fresh component set seeded from the reference date.
Sourcepub fn create_result(
&self,
index: usize,
end_index: usize,
start: FastComponents,
end: Option<FastComponents>,
) -> ParsedResult
pub fn create_result( &self, index: usize, end_index: usize, start: FastComponents, end: Option<FastComponents>, ) -> ParsedResult
Build a ParsedResult for a matched span.
Sourcepub fn has_token_type(&self, token_type: TokenType) -> bool
pub fn has_token_type(&self, token_type: TokenType) -> bool
Return true when the scanner found a token of the given type.
Auto Trait Implementations§
impl<'a> Freeze for ParsingContext<'a>
impl<'a> RefUnwindSafe for ParsingContext<'a>
impl<'a> Send for ParsingContext<'a>
impl<'a> Sync for ParsingContext<'a>
impl<'a> Unpin for ParsingContext<'a>
impl<'a> UnsafeUnpin for ParsingContext<'a>
impl<'a> UnwindSafe for ParsingContext<'a>
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