Skip to main content

cc_audit/config/
parsers.rs

1//! String parsers for configuration values.
2//!
3//! These functions parse string representations from CLI args
4//! or config files into typed enums.
5
6use crate::{BadgeFormat, ClientType, Confidence, OutputFormat, RuleSeverity, ScanType, Severity};
7
8/// Parse badge format from string using FromStr.
9pub fn parse_badge_format(s: Option<&str>) -> Option<BadgeFormat> {
10    s?.parse().ok()
11}
12
13/// Parse client type from string using FromStr.
14pub fn parse_client_type(s: Option<&str>) -> Option<ClientType> {
15    s?.parse().ok()
16}
17
18/// Parse output format from string using FromStr.
19pub fn parse_output_format(s: Option<&str>) -> Option<OutputFormat> {
20    s?.parse().ok()
21}
22
23/// Parse scan type from string using FromStr.
24pub fn parse_scan_type(s: Option<&str>) -> Option<ScanType> {
25    s?.parse().ok()
26}
27
28/// Parse confidence level from string using FromStr.
29pub fn parse_confidence(s: Option<&str>) -> Option<Confidence> {
30    s?.parse().ok()
31}
32
33/// Parse severity level from string using FromStr.
34pub fn parse_severity(s: Option<&str>) -> Option<Severity> {
35    s?.parse().ok()
36}
37
38/// Parse rule severity level from string using FromStr.
39pub fn parse_rule_severity(s: Option<&str>) -> Option<RuleSeverity> {
40    s?.parse().ok()
41}