Skip to main content

sql_splitter/redactor/strategy/
skip.rs

1//! Skip strategy - no redaction, passthrough.
2
3use super::{RedactValue, Strategy, StrategyKind};
4
5/// Strategy that passes values through unchanged
6#[derive(Debug, Clone, Default)]
7pub struct SkipStrategy;
8
9impl SkipStrategy {
10    pub fn new() -> Self {
11        Self
12    }
13}
14
15impl Strategy for SkipStrategy {
16    fn apply(&self, value: &RedactValue, _rng: &mut dyn rand::RngCore) -> RedactValue {
17        // Return value unchanged
18        value.clone()
19    }
20
21    fn kind(&self) -> StrategyKind {
22        StrategyKind::Skip
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    use rand::SeedableRng;
30
31    #[test]
32    fn test_skip_strategy() {
33        let strategy = SkipStrategy::new();
34        let mut rng = rand::rngs::StdRng::seed_from_u64(42);
35
36        // String passes through
37        let result = strategy.apply(&RedactValue::String("test".to_string()), &mut rng);
38        match result {
39            RedactValue::String(s) => assert_eq!(s, "test"),
40            _ => panic!("Expected String"),
41        }
42
43        // Integer passes through
44        let result = strategy.apply(&RedactValue::Integer(123), &mut rng);
45        match result {
46            RedactValue::Integer(i) => assert_eq!(i, 123),
47            _ => panic!("Expected Integer"),
48        }
49
50        // NULL passes through
51        let result = strategy.apply(&RedactValue::Null, &mut rng);
52        assert!(matches!(result, RedactValue::Null));
53    }
54}