1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// THIS IS A GENERATED FILE
// If anything in this file needs to be updated, it needs to be fixed in reso_dd_generator
use serde::{Deserialize, Serialize};

/// [CommonWalls Lookups](https://ddwiki.reso.org/display/DDW17/CommonWalls+Lookups)
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum CommonWalls {
    /// "[1 Common Wall](https://ddwiki.reso.org/display/DDW17/1+Common+Wall)": The dwelling being sold has one common wall with another property that is not part of the sale.  Also known as an attached structure.
    _1CommonWall,

    /// "[2+ Common Walls](https://ddwiki.reso.org/pages/viewpage.action?pageId=29244057)": The dwelling being sold has two or more common walls with another property that is not part of the sale.  Also known as an attached structure.
    _2PlusCommonWalls,

    /// "[End Unit](https://ddwiki.reso.org/display/DDW17/End+Unit)": The dwelling being sold has one or more common walls with another property that is not part of the sale and is at the end of a row of units.  Also known as an attached structure.
    EndUnit,

    /// "[No Common Walls](https://ddwiki.reso.org/display/DDW17/No+Common+Walls)": The dwelling being sold has no attached structures that are not part of the sale.  Also know as a detached structure.
    NoCommonWalls,

    /// "[No One Above](https://ddwiki.reso.org/display/DDW17/No+One+Above)": The property is attached to another dwelling that is not part of the sale, but there is no unit above the one being sold.
    NoOneAbove,

    /// "[No One Below](https://ddwiki.reso.org/display/DDW17/No+One+Below)": The property is attached to another dwelling that is not part of the sale, but there is no unit below the one being sold.
    NoOneBelow,

    /// A value that was not defined by the enumeration
    OpenEnumeration(String),
}

impl crate::ResoEnumeration for CommonWalls {
    fn from_str(s: &str) -> CommonWalls {
        match s {
            "1 Common Wall" => CommonWalls::_1CommonWall,

            "2+ Common Walls" => CommonWalls::_2PlusCommonWalls,

            "End Unit" => CommonWalls::EndUnit,

            "No Common Walls" => CommonWalls::NoCommonWalls,

            "No One Above" => CommonWalls::NoOneAbove,

            "No One Below" => CommonWalls::NoOneBelow,

            _ => CommonWalls::OpenEnumeration(s.into()),
        }
    }

    fn from_string(s: String) -> CommonWalls {
        match s.as_ref() {
            "1 Common Wall" => CommonWalls::_1CommonWall,

            "2+ Common Walls" => CommonWalls::_2PlusCommonWalls,

            "End Unit" => CommonWalls::EndUnit,

            "No Common Walls" => CommonWalls::NoCommonWalls,

            "No One Above" => CommonWalls::NoOneAbove,

            "No One Below" => CommonWalls::NoOneBelow,

            _ => CommonWalls::OpenEnumeration(s),
        }
    }

    fn to_str(&self) -> &str {
        match self {
            CommonWalls::_1CommonWall => "1 Common Wall",

            CommonWalls::_2PlusCommonWalls => "2+ Common Walls",

            CommonWalls::EndUnit => "End Unit",

            CommonWalls::NoCommonWalls => "No Common Walls",

            CommonWalls::NoOneAbove => "No One Above",

            CommonWalls::NoOneBelow => "No One Below",

            CommonWalls::OpenEnumeration(ref s) => s,
        }
    }

    fn into_string(self) -> String {
        match self {
            CommonWalls::_1CommonWall => "1 Common Wall".into(),

            CommonWalls::_2PlusCommonWalls => "2+ Common Walls".into(),

            CommonWalls::EndUnit => "End Unit".into(),

            CommonWalls::NoCommonWalls => "No Common Walls".into(),

            CommonWalls::NoOneAbove => "No One Above".into(),

            CommonWalls::NoOneBelow => "No One Below".into(),

            CommonWalls::OpenEnumeration(s) => s,
        }
    }

    fn fallback_value(&self) -> Option<&str> {
        match self {
            CommonWalls::OpenEnumeration(ref s) => Some(s),
            _ => None,
        }
    }
}

impl From<String> for CommonWalls {
    fn from(s: String) -> CommonWalls {
        match s.as_ref() {
            "1 Common Wall" => CommonWalls::_1CommonWall,

            "2+ Common Walls" => CommonWalls::_2PlusCommonWalls,

            "End Unit" => CommonWalls::EndUnit,

            "No Common Walls" => CommonWalls::NoCommonWalls,

            "No One Above" => CommonWalls::NoOneAbove,

            "No One Below" => CommonWalls::NoOneBelow,

            _ => CommonWalls::OpenEnumeration(s),
        }
    }
}

impl From<&str> for CommonWalls {
    fn from(s: &str) -> CommonWalls {
        match s {
            "1 Common Wall" => CommonWalls::_1CommonWall,

            "2+ Common Walls" => CommonWalls::_2PlusCommonWalls,

            "End Unit" => CommonWalls::EndUnit,

            "No Common Walls" => CommonWalls::NoCommonWalls,

            "No One Above" => CommonWalls::NoOneAbove,

            "No One Below" => CommonWalls::NoOneBelow,

            _ => CommonWalls::OpenEnumeration(s.into()),
        }
    }
}

impl<'a> From<&'a CommonWalls> for &'a str {
    fn from(s: &'a CommonWalls) -> &'a str {
        match s {
            CommonWalls::_1CommonWall => "1 Common Wall",

            CommonWalls::_2PlusCommonWalls => "2+ Common Walls",

            CommonWalls::EndUnit => "End Unit",

            CommonWalls::NoCommonWalls => "No Common Walls",

            CommonWalls::NoOneAbove => "No One Above",

            CommonWalls::NoOneBelow => "No One Below",

            CommonWalls::OpenEnumeration(s) => s,
        }
    }
}

impl Serialize for CommonWalls {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.into())
    }
}

impl<'de> Deserialize<'de> for CommonWalls {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = String::deserialize(deserializer)?;
        Ok(From::from(s))
    }
}