deepl_openapi/models/
formality.rs

1/// Sets whether the translated text should lean towards formal or informal language.
2///         This feature currently only works for target languages
3///         `DE` (German),
4///         `FR` (French),
5///         `IT` (Italian),
6///         `ES` (Spanish),
7///         `NL` (Dutch),
8///         `PL` (Polish),
9///         `PT-PT`,
10///         `PT-BR` (Portuguese)
11///         and `RU` (Russian).
12///       Setting this parameter with a target language that does not support formality will fail,
13///         unless one of the `prefer_...` options are used.
14///         Possible options are:
15///           * `default` (default)
16///           * `more` - for a more formal language
17///           * `less` - for a more informal language
18///           * `prefer_more` - for a more formal language if available, otherwise fallback to default formality
19///           * `prefer_less` - for a more informal language if available, otherwise fallback to default formality
20///
21
22#[derive(
23    Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Default,
24)]
25pub enum Formality {
26    #[default]
27    #[serde(rename = "default")]
28    Default,
29    #[serde(rename = "more")]
30    More,
31    #[serde(rename = "less")]
32    Less,
33    #[serde(rename = "prefer_more")]
34    PreferMore,
35    #[serde(rename = "prefer_less")]
36    PreferLess,
37}
38
39impl ToString for Formality {
40    fn to_string(&self) -> String {
41        match self {
42            Self::Default => String::from("default"),
43            Self::More => String::from("more"),
44            Self::Less => String::from("less"),
45            Self::PreferMore => String::from("prefer_more"),
46            Self::PreferLess => String::from("prefer_less"),
47        }
48    }
49}