Repository: tikv/tikv
File: components/log_wrappers/src/lib.rs (Rust)

Code before:
}

impl FromStr for RedactOption {
    type Err = String;
    fn from_str(s: &str) -> Result<RedactOption, String> {
        match s {
            "" => Ok(RedactOption::default()),
            "on" | "ON" | "true" | "TRUE" | "True" => Ok(RedactOption::On),
            "off" | "OFF" | "false" | "FALSE" | "False" => Ok(RedactOption::Off),
            "marker" | "MARKER" => Ok(RedactOption::Marker),
            s => Err(format!(
                "expect: marker | on | off | true | false, got: {s:?}"
            )),
        }
    }
}

impl TryFrom<ConfigValue> for RedactOption {
    type Error = String;
    fn try_from(value: ConfigValue) -> Result<Self, Self::Error> {
        match value {
            ConfigValue::Bool(true) => Ok(RedactOption::On),
            ConfigValue::Bool(false) => Ok(RedactOption::Off),
            ConfigValue::String(s) => RedactOption::from_str(&s),
            _ => Err(format!(
                "expect: marker, marker | on | off | true | false, got: {value:?}"
            )),
        }
    }
}

impl From<RedactOption> for ConfigValue {
    fn from(option: RedactOption) -> Self {
        ConfigValue::String(option.to_string())
    }
}

impl Serialize for RedactOption {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        match self {
            Self::On => true.serialize(serializer),
            Self::Off => false.serialize(serializer),
            Self::Marker => "marker".serialize(serializer),
        }
    }
}

impl<'de> Deserialize<'de> for RedactOption {

Review comment (suggestion):
```suggestion
                "expect: marker | on | off | true | false, got: {value:?}"
```

Code after:
}

impl FromStr for RedactOption {
    type Err = String;
    fn from_str(s: &str) -> Result<RedactOption, String> {
        match s {
            "" => Ok(RedactOption::default()),
            "on" | "ON" | "true" | "TRUE" | "True" => Ok(RedactOption::On),
            "off" | "OFF" | "false" | "FALSE" | "False" => Ok(RedactOption::Off),
            "marker" | "MARKER" => Ok(RedactOption::Marker),
            s => Err(format!(
                "expect: marker | on | off | true | false, got: {s:?}"
            )),
        }
    }
}

impl TryFrom<ConfigValue> for RedactOption {
    type Error = String;
    fn try_from(value: ConfigValue) -> Result<Self, Self::Error> {
        match value {
            ConfigValue::Bool(true) => Ok(RedactOption::On),
            ConfigValue::Bool(false) => Ok(RedactOption::Off),
            ConfigValue::String(s) => RedactOption::from_str(&s),
            _ => Err(format!(
                "expect: marker | on | off | true | false, got: {value:?}"
            )),
        }
    }
}

impl From<RedactOption> for ConfigValue {
    fn from(option: RedactOption) -> Self {
        ConfigValue::String(option.to_string())
    }
}

impl Serialize for RedactOption {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        match self {
            Self::On => true.serialize(serializer),
            Self::Off => false.serialize(serializer),
            Self::Marker => "marker".serialize(serializer),
        }
    }
}

impl<'de> Deserialize<'de> for RedactOption {