redact_engine/
data.rs

1//! Common structs
2use serde_derive::Deserialize;
3
4/// Default redact placeholder
5pub const REDACT_PLACEHOLDER: &str = "[TEXT_REDACTED]";
6
7#[derive(Debug, Deserialize, Clone)]
8/// Describe redaction by Pattern
9pub struct Pattern {
10    #[serde(with = "serde_regex")]
11    /// regex Pattern
12    pub test: regex::Regex,
13    /// capture group to redact
14    pub group: usize,
15}
16
17#[derive(Debug, Deserialize, Clone)]
18/// Redact information
19pub struct Info {
20    /// redacted string
21    pub string: String,
22    /// captures information
23    pub captures: Vec<Captures>,
24}
25
26#[derive(Debug, Deserialize, Clone)]
27/// Capture details
28pub struct Captures {
29    /// the captured text
30    pub text: String,
31    /// the match regex string
32    pub test: String,
33    /// Position capture details
34    pub position: Option<Position>,
35}
36
37#[derive(Debug, Deserialize, Clone)]
38pub struct Position {
39    /// capture line number
40    pub line: usize,
41    /// start caption position
42    pub start_offset: usize,
43    /// end caption position
44    pub end_offset: usize,
45}