1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Track `Regexp` global state.

/// Track the state of `Regexp` globals and global interpreter state.
pub trait Regexp {
    /// Concrete error type for errors encountered when manipulating `Regexp`
    /// state.
    type Error;

    /// Retrieve the current number of set `Regexp` global variables.
    ///
    /// `Regexp` global variables like `$1` and `$7` are defined after certain
    /// `Regexp` matching methods for each capturing group in the regular
    /// expression.
    ///
    /// # Errors
    ///
    /// If the `Regexp` state is inaccessible, an error is returned.
    fn active_regexp_globals(&self) -> Result<usize, Self::Error>;

    /// Set the current number of set `Regexp` global variables.
    ///
    /// `Regexp` global variables like `$1` and `$7` are defined after certain
    /// `Regexp` matching methods for each capturing group in the regular
    /// expression.
    ///
    /// # Errors
    ///
    /// If the `Regexp` state is inaccessible, an error is returned.
    fn set_active_regexp_globals(&mut self, count: usize) -> Result<(), Self::Error>;

    /// Clear all `Regexp` state.
    ///
    /// # Errors
    ///
    /// If the `Regexp` state is inaccessible, an error is returned.
    fn clear_regexp(&mut self) -> Result<(), Self::Error>;
}