destination/import/
josephine_county.rs

1//! The `josephine_county` module contains data types for importing addresses from ECSO and
2//! Josephine County.
3use crate::{
4    Address, AddressError, AddressErrorKind, AddressStatus, Addresses, Cartesian, Decode,
5    Geographic, IntoBin, IntoCsv, Io, State, StreetNamePostType, StreetNamePreDirectional,
6    StreetNamePreModifier, StreetNamePreType, StreetSeparator, SubaddressType,
7    deserialize_arcgis_data, from_bin, from_csv, to_bin, to_csv, zero_floor,
8};
9use derive_more::{Deref, DerefMut};
10use serde::{Deserialize, Serialize};
11use std::path::Path;
12
13/// The `JosephineCountyAddress2024` struct represents an address site point for Josephine County,
14/// consistent with the schema adopted by the agency in April of 2024.
15#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Deserialize, Serialize)]
16pub struct JosephineCountyAddress2024 {
17    /// The `address_number` field represents the address number component of the complete address
18    /// number.
19    #[serde(rename = "add_number")]
20    pub address_number: i64,
21    /// The `address_number_suffix` field represents the address number suffix component of the complete
22    /// address number.
23    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "addnum_suf")]
24    pub address_number_suffix: Option<String>,
25    /// The `street_name_pre_directional` field represents the street name pre directional component of the
26    /// complete street name.
27    #[serde(
28        deserialize_with = "StreetNamePreDirectional::deserialize_mixed",
29        rename = "st_predir"
30    )]
31    pub street_name_pre_directional: Option<StreetNamePreDirectional>,
32    /// The `street_name_pre_modifier` field represents the street name pre modifier component of the complete
33    /// street name.
34    #[serde(
35        deserialize_with = "StreetNamePreModifier::deserialize_mixed",
36        rename = "st_premod"
37    )]
38    pub street_name_pre_modifier: Option<StreetNamePreModifier>,
39    /// The `street_name_pre_type` field represents the street name pre type component of the complete street
40    /// name.
41    #[serde(
42        deserialize_with = "StreetNamePreType::deserialize_mixed",
43        rename = "st_pretyp"
44    )]
45    pub street_name_pre_type: Option<StreetNamePreType>,
46    /// The `street_name_separator` field represents the separator element component of the complete street
47    /// name.
48    #[serde(
49        deserialize_with = "StreetSeparator::deserialize_mixed",
50        rename = "st_presep"
51    )]
52    pub street_name_separator: Option<StreetSeparator>,
53    /// The `street_name` field represents the street name component of the complete street name.
54    #[serde(rename = "st_name")]
55    pub street_name: String,
56    /// The `street_name_post_type` field represents the street name post type component of the complete street
57    /// name.
58    #[serde(
59        deserialize_with = "StreetNamePostType::deserialize_mixed",
60        rename = "st_postyp"
61    )]
62    pub street_name_post_type: Option<StreetNamePostType>,
63    /// The `subaddress_type` field represents the subaddress type component of the complete
64    /// subaddress.
65    #[serde(
66        deserialize_with = "SubaddressType::deserialize_mixed",
67        rename = "unittype"
68    )]
69    pub subaddress_type: Option<SubaddressType>,
70    /// The `subaddress_identifier` field represents the subaddress identifier component of the complete
71    /// subaddress.
72    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "unit")]
73    pub subaddress_identifier: Option<String>,
74    /// The `floor` field represents the floor identifier, corresponding to the `Floor` field from the NENA standard.
75    #[serde(deserialize_with = "zero_floor")]
76    pub floor: Option<i64>,
77    /// The `complete_street_address` field represents the full street address as a string.
78    #[serde(rename = "st_fullad")]
79    pub complete_street_address: String,
80    /// The `postal_community` field represents the postal community component of the address,
81    /// being either the unincorporated or incorporated municipality name.
82    #[serde(rename = "uninc_comm")]
83    pub postal_community: String,
84    /// The `zip_code` field represents the postal zip code of the address.
85    #[serde(rename = "post_code")]
86    pub zip_code: i64,
87    /// The `state_name` field represents the state name component of the address.
88    #[serde(deserialize_with = "State::deserialize_mixed")]
89    #[serde(rename = "state")]
90    pub state_name: State,
91    /// The `status` field represents the local status of the address as determined by the relevant
92    /// addressing authority.
93    pub status: AddressStatus,
94}
95
96impl Address for JosephineCountyAddress2024 {
97    fn number(&self) -> i64 {
98        self.address_number
99    }
100
101    fn number_mut(&mut self) -> &mut i64 {
102        &mut self.address_number
103    }
104
105    fn number_suffix(&self) -> &Option<String> {
106        &self.address_number_suffix
107    }
108
109    fn number_suffix_mut(&mut self) -> &mut Option<String> {
110        &mut self.address_number_suffix
111    }
112
113    fn directional(&self) -> &Option<StreetNamePreDirectional> {
114        &self.street_name_pre_directional
115    }
116
117    fn directional_mut(&mut self) -> &mut Option<StreetNamePreDirectional> {
118        &mut self.street_name_pre_directional
119    }
120
121    fn street_name_pre_modifier(&self) -> &Option<StreetNamePreModifier> {
122        &self.street_name_pre_modifier
123    }
124
125    fn street_name_pre_modifier_mut(&mut self) -> &mut Option<StreetNamePreModifier> {
126        &mut self.street_name_pre_modifier
127    }
128
129    fn street_name_pre_type(&self) -> &Option<StreetNamePreType> {
130        &self.street_name_pre_type
131    }
132
133    fn street_name_pre_type_mut(&mut self) -> &mut Option<StreetNamePreType> {
134        &mut self.street_name_pre_type
135    }
136
137    fn street_name_separator(&self) -> &Option<StreetSeparator> {
138        &self.street_name_separator
139    }
140
141    fn street_name_separator_mut(&mut self) -> &mut Option<StreetSeparator> {
142        &mut self.street_name_separator
143    }
144
145    fn street_name(&self) -> &String {
146        &self.street_name
147    }
148
149    fn street_name_mut(&mut self) -> &mut String {
150        &mut self.street_name
151    }
152
153    fn street_type(&self) -> &Option<StreetNamePostType> {
154        &self.street_name_post_type
155    }
156
157    fn street_type_mut(&mut self) -> &mut Option<StreetNamePostType> {
158        &mut self.street_name_post_type
159    }
160
161    fn subaddress_id(&self) -> &Option<String> {
162        &self.subaddress_identifier
163    }
164
165    fn subaddress_id_mut(&mut self) -> &mut Option<String> {
166        &mut self.subaddress_identifier
167    }
168
169    fn subaddress_type(&self) -> &Option<SubaddressType> {
170        &self.subaddress_type
171    }
172
173    fn subaddress_type_mut(&mut self) -> &mut Option<SubaddressType> {
174        &mut self.subaddress_type
175    }
176
177    fn floor(&self) -> &Option<i64> {
178        &self.floor
179    }
180
181    fn floor_mut(&mut self) -> &mut Option<i64> {
182        &mut self.floor
183    }
184
185    fn building(&self) -> &Option<String> {
186        &None
187    }
188
189    fn building_mut(&mut self) -> &mut Option<String> {
190        &mut self.address_number_suffix
191    }
192
193    fn zip(&self) -> i64 {
194        self.zip_code
195    }
196
197    fn zip_mut(&mut self) -> &mut i64 {
198        &mut self.zip_code
199    }
200
201    fn postal_community(&self) -> &String {
202        &self.postal_community
203    }
204
205    fn postal_community_mut(&mut self) -> &mut String {
206        &mut self.postal_community
207    }
208
209    fn state(&self) -> &State {
210        &self.state_name
211    }
212
213    fn state_mut(&mut self) -> &mut State {
214        &mut self.state_name
215    }
216
217    fn status(&self) -> &AddressStatus {
218        &self.status
219    }
220
221    fn status_mut(&mut self) -> &mut AddressStatus {
222        &mut self.status
223    }
224}
225
226/// The `JosephineCountyAddresses2024` struct holds a vector of type
227/// ['JosephineCountyAddress2024'].
228#[derive(Debug, Default, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Deref, DerefMut)]
229pub struct JosephineCountyAddresses2024(Vec<JosephineCountyAddress2024>);
230
231impl Addresses<JosephineCountyAddress2024> for JosephineCountyAddresses2024 {}
232
233impl IntoBin<JosephineCountyAddresses2024> for JosephineCountyAddresses2024 {
234    fn load<P: AsRef<Path>>(path: P) -> Result<Self, AddressError> {
235        let config = bincode::config::standard();
236        match from_bin(path) {
237            Ok(records) => {
238                let (result, _) = bincode::serde::decode_from_slice::<
239                    Self,
240                    bincode::config::Configuration,
241                >(&records, config)
242                .map_err(|source| Decode::new(source, line!(), file!().into()))?;
243                Ok(result)
244            }
245            Err(source) => Err(AddressErrorKind::from(source).into()),
246        }
247    }
248
249    fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), AddressError> {
250        to_bin(self, path)
251    }
252}
253
254impl IntoCsv<JosephineCountyAddresses2024> for JosephineCountyAddresses2024 {
255    fn from_csv<P: AsRef<Path>>(path: P) -> Result<Self, Io> {
256        let records = from_csv(path)?;
257        Ok(Self(records))
258    }
259
260    fn to_csv<P: AsRef<Path>>(&mut self, path: P) -> Result<(), AddressErrorKind> {
261        to_csv(&mut self.0, path.as_ref().into())
262    }
263}
264
265/// The `JosephineCountySpatialAddress2024` struct represents an address site point for Josephine County that includes geographic and projected coordinate information,
266/// consistent with the schema adopted by the agency in April of 2024.
267#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Deserialize, Serialize)]
268pub struct JosephineCountySpatialAddress2024 {
269    /// The `address_number` field represents the address number component of the complete address
270    /// number.
271    #[serde(rename = "add_number")]
272    pub address_number: i64,
273    /// The `address_number_suffix` field represents the address number suffix component of the complete
274    /// address number.
275    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "addnum_suf")]
276    pub address_number_suffix: Option<String>,
277    /// The `street_name_pre_directional` field represents the street name pre directional component of the
278    /// complete street name.
279    #[serde(
280        deserialize_with = "StreetNamePreDirectional::deserialize_mixed",
281        rename = "st_predir"
282    )]
283    pub street_name_pre_directional: Option<StreetNamePreDirectional>,
284    /// The `street_name_pre_modifier` field represents the street name pre modifier component of the complete
285    /// street name.
286    #[serde(
287        deserialize_with = "StreetNamePreModifier::deserialize_mixed",
288        rename = "st_premod"
289    )]
290    pub street_name_pre_modifier: Option<StreetNamePreModifier>,
291    /// The `street_name_pre_type` field represents the street name pre type component of the complete street
292    /// name.
293    #[serde(
294        deserialize_with = "StreetNamePreType::deserialize_mixed",
295        rename = "st_pretyp"
296    )]
297    pub street_name_pre_type: Option<StreetNamePreType>,
298    /// The `street_name_separator` field represents the separator element component of the complete street
299    /// name.
300    #[serde(
301        deserialize_with = "StreetSeparator::deserialize_mixed",
302        rename = "st_presep"
303    )]
304    pub street_name_separator: Option<StreetSeparator>,
305    /// The `street_name` field represents the street name component of the complete street name.
306    #[serde(rename = "st_name")]
307    pub street_name: String,
308    /// The `street_name_post_type` field represents the street name post type component of the complete street
309    /// name.
310    #[serde(
311        deserialize_with = "StreetNamePostType::deserialize_mixed",
312        rename = "st_postyp"
313    )]
314    pub street_name_post_type: Option<StreetNamePostType>,
315    /// The `subaddress_type` field represents the subaddress type component of the complete
316    /// subaddress.
317    #[serde(
318        deserialize_with = "SubaddressType::deserialize_mixed",
319        rename = "unittype"
320    )]
321    pub subaddress_type: Option<SubaddressType>,
322    /// The `subaddress_identifier` field represents the subaddress identifier component of the complete
323    /// subaddress.
324    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "unit")]
325    pub subaddress_identifier: Option<String>,
326    /// The `floor` field represents the floor identifier, corresponding to the `Floor` field from the NENA standard.
327    #[serde(deserialize_with = "zero_floor")]
328    pub floor: Option<i64>,
329    /// The `complete_street_address` field represents the full street address as a string.
330    #[serde(rename = "st_fullad")]
331    pub complete_street_address: String,
332    /// The `postal_community` field represents the postal community component of the address,
333    /// being either the unincorporated or incorporated municipality name.
334    #[serde(rename = "uninc_comm")]
335    pub postal_community: String,
336    /// The `zip_code` field represents the postal zip code of the address.
337    #[serde(rename = "post_code")]
338    pub zip_code: i64,
339    /// The `state_name` field represents the state name component of the address.
340    #[serde(deserialize_with = "State::deserialize_mixed")]
341    #[serde(rename = "state")]
342    pub state_name: State,
343    /// The `status` field represents the local status of the address as determined by the relevant
344    /// addressing authority.
345    pub status: AddressStatus,
346    /// The `x` field represents the cartesian X portion of the projected coordinates of the
347    /// address.
348    pub x: f64,
349    /// The `y` field represents the cartesian Y portion of the projected coordinates of the
350    /// address.
351    pub y: f64,
352    /// The `lat` field represents the latitude of the geographic coordinates for the address.
353    #[serde(rename = "latitude")]
354    pub lat: f64,
355    /// The `lon` field represents the longitude of the geographic coordinates for the address.
356    #[serde(rename = "longitude")]
357    pub lon: f64,
358}
359
360impl Address for JosephineCountySpatialAddress2024 {
361    fn number(&self) -> i64 {
362        self.address_number
363    }
364
365    fn number_mut(&mut self) -> &mut i64 {
366        &mut self.address_number
367    }
368
369    fn number_suffix(&self) -> &Option<String> {
370        &self.address_number_suffix
371    }
372
373    fn number_suffix_mut(&mut self) -> &mut Option<String> {
374        &mut self.address_number_suffix
375    }
376
377    fn directional(&self) -> &Option<StreetNamePreDirectional> {
378        &self.street_name_pre_directional
379    }
380
381    fn directional_mut(&mut self) -> &mut Option<StreetNamePreDirectional> {
382        &mut self.street_name_pre_directional
383    }
384
385    fn street_name_pre_modifier(&self) -> &Option<StreetNamePreModifier> {
386        &self.street_name_pre_modifier
387    }
388
389    fn street_name_pre_modifier_mut(&mut self) -> &mut Option<StreetNamePreModifier> {
390        &mut self.street_name_pre_modifier
391    }
392
393    fn street_name_pre_type(&self) -> &Option<StreetNamePreType> {
394        &self.street_name_pre_type
395    }
396
397    fn street_name_pre_type_mut(&mut self) -> &mut Option<StreetNamePreType> {
398        &mut self.street_name_pre_type
399    }
400
401    fn street_name_separator(&self) -> &Option<StreetSeparator> {
402        &self.street_name_separator
403    }
404
405    fn street_name_separator_mut(&mut self) -> &mut Option<StreetSeparator> {
406        &mut self.street_name_separator
407    }
408
409    fn street_name(&self) -> &String {
410        &self.street_name
411    }
412
413    fn street_name_mut(&mut self) -> &mut String {
414        &mut self.street_name
415    }
416
417    fn street_type(&self) -> &Option<StreetNamePostType> {
418        &self.street_name_post_type
419    }
420
421    fn street_type_mut(&mut self) -> &mut Option<StreetNamePostType> {
422        &mut self.street_name_post_type
423    }
424
425    fn subaddress_id(&self) -> &Option<String> {
426        &self.subaddress_identifier
427    }
428
429    fn subaddress_id_mut(&mut self) -> &mut Option<String> {
430        &mut self.subaddress_identifier
431    }
432
433    fn subaddress_type(&self) -> &Option<SubaddressType> {
434        &self.subaddress_type
435    }
436
437    fn subaddress_type_mut(&mut self) -> &mut Option<SubaddressType> {
438        &mut self.subaddress_type
439    }
440
441    fn floor(&self) -> &Option<i64> {
442        &self.floor
443    }
444
445    fn floor_mut(&mut self) -> &mut Option<i64> {
446        &mut self.floor
447    }
448
449    fn building(&self) -> &Option<String> {
450        &None
451    }
452
453    fn building_mut(&mut self) -> &mut Option<String> {
454        &mut self.address_number_suffix
455    }
456
457    fn zip(&self) -> i64 {
458        self.zip_code
459    }
460
461    fn zip_mut(&mut self) -> &mut i64 {
462        &mut self.zip_code
463    }
464
465    fn postal_community(&self) -> &String {
466        &self.postal_community
467    }
468
469    fn postal_community_mut(&mut self) -> &mut String {
470        &mut self.postal_community
471    }
472
473    fn state(&self) -> &State {
474        &self.state_name
475    }
476
477    fn state_mut(&mut self) -> &mut State {
478        &mut self.state_name
479    }
480
481    fn status(&self) -> &AddressStatus {
482        &self.status
483    }
484
485    fn status_mut(&mut self) -> &mut AddressStatus {
486        &mut self.status
487    }
488}
489
490impl Cartesian for JosephineCountySpatialAddress2024 {
491    fn x(&self) -> f64 {
492        self.x
493    }
494
495    fn y(&self) -> f64 {
496        self.y
497    }
498}
499
500impl Geographic for JosephineCountySpatialAddress2024 {
501    fn latitude(&self) -> f64 {
502        self.lat
503    }
504
505    fn longitude(&self) -> f64 {
506        self.lon
507    }
508}
509
510/// The `JosephineCountySpatialAddresses2024` struct holds a vector of type
511/// ['JosephineCountySpatialAddress2024'].
512#[derive(Debug, Default, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Deref, DerefMut)]
513pub struct JosephineCountySpatialAddresses2024(Vec<JosephineCountySpatialAddress2024>);
514
515impl Addresses<JosephineCountySpatialAddress2024> for JosephineCountySpatialAddresses2024 {}
516
517impl IntoBin<JosephineCountySpatialAddresses2024> for JosephineCountySpatialAddresses2024 {
518    fn load<P: AsRef<Path>>(path: P) -> Result<Self, AddressError> {
519        let config = bincode::config::standard();
520        match from_bin(path) {
521            Ok(records) => {
522                let (results, _) = bincode::serde::decode_from_slice::<
523                    Self,
524                    bincode::config::Configuration,
525                >(&records, config)
526                .map_err(|source| Decode::new(source, line!(), file!().into()))?;
527                Ok(results)
528            }
529            Err(source) => Err(AddressErrorKind::from(source).into()),
530        }
531    }
532
533    fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), AddressError> {
534        to_bin(self, path)
535    }
536}
537
538impl IntoCsv<JosephineCountySpatialAddresses2024> for JosephineCountySpatialAddresses2024 {
539    fn from_csv<P: AsRef<Path>>(path: P) -> Result<Self, Io> {
540        let records = from_csv(path)?;
541        Ok(Self(records))
542    }
543
544    fn to_csv<P: AsRef<Path>>(&mut self, path: P) -> Result<(), AddressErrorKind> {
545        to_csv(&mut self.0, path.as_ref().into())
546    }
547}
548
549/// The `JosephineCountyAddress` struct represents an address site point for Josephine County,
550/// prior to the schema adopted by the agency in April of 2024.
551#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Deserialize, Serialize)]
552pub struct JosephineCountyAddress {
553    /// The `taxlot` field represents the map tax lot number of the parcel on which the address
554    /// is located.
555    #[serde(deserialize_with = "deserialize_arcgis_data")]
556    pub taxlot: Option<String>,
557    /// The `address_number` field represents the address number component of the complete address
558    /// number.
559    #[serde(rename = "stnum")]
560    pub address_number: i64,
561    /// The `address_number_suffix` field represents the address number suffix component of the complete
562    /// address number.
563    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "stnumsuf")]
564    pub address_number_suffix: Option<String>,
565    /// The `street_name_pre_directional` field represents the street name pre directional component of the
566    /// complete street name.
567    #[serde(
568        deserialize_with = "StreetNamePreDirectional::deserialize_abbreviated",
569        rename = "predir"
570    )]
571    pub street_name_pre_directional: Option<StreetNamePreDirectional>,
572    /// The `street_name` field represents the street name component of the complete street name.
573    #[serde(rename = "name")]
574    pub street_name: String,
575    /// The `street_name_post_type` field represents the street name post type component of the complete street
576    /// name.
577    #[serde(
578        deserialize_with = "StreetNamePostType::deserialize_mixed",
579        // deserialize_with = "deserialize_abbreviated_post_type",
580        rename = "type"
581    )]
582    pub street_name_post_type: Option<StreetNamePostType>,
583    /// The `subaddress_type` field represents the subaddress type component of the complete
584    /// subaddress.
585    #[serde(
586        deserialize_with = "SubaddressType::deserialize_abbreviated",
587        rename = "unit_type"
588    )]
589    pub subaddress_type: Option<SubaddressType>,
590    /// The `subaddress_identifier` field represents the subaddress identifier component of the complete
591    /// subaddress.
592    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "unit")]
593    pub subaddress_identifier: Option<String>,
594    /// The `floor` field represents the floor identifier, corresponding to the `Floor` field from the NENA standard.
595    #[serde(deserialize_with = "zero_floor")]
596    pub floor: Option<i64>,
597    /// The `complete_street_address` field represents the full street address as a string.
598    #[serde(rename = "address")]
599    pub complete_street_address: String,
600    /// The `postal_community` field represents the postal community component of the address,
601    /// being either the unincorporated or incorporated municipality name.
602    #[serde(rename = "postcomm")]
603    pub postal_community: String,
604    /// The `zip_code` field represents the postal zip code of the address.
605    #[serde(rename = "zip")]
606    pub zip_code: i64,
607    /// The `state_name` field represents the state name component of the address.
608    #[serde(deserialize_with = "State::deserialize_mixed")]
609    #[serde(rename = "state")]
610    pub state_name: State,
611    /// The `status` field represents the local status of the address as determined by the relevant
612    /// addressing authority.
613    pub status: AddressStatus,
614    /// The `street_name_pre_modifier` field holds the pre-modifier element of the complete street
615    /// name.
616    #[serde(
617        deserialize_with = "StreetNamePreModifier::deserialize_mixed",
618        rename = "premod"
619    )]
620    pub street_name_pre_modifier: Option<StreetNamePreModifier>,
621    /// The `street_name_pre_type` field holds the pre-type element of the complete street
622    /// name.
623    #[serde(
624        deserialize_with = "StreetNamePreType::deserialize_mixed",
625        rename = "pretype"
626    )]
627    pub street_name_pre_type: Option<StreetNamePreType>,
628    /// The `street_separator` field holds the separator element of the complete street
629    /// name.
630    #[serde(
631        deserialize_with = "StreetSeparator::deserialize_mixed",
632        rename = "structdesc"
633    )]
634    pub street_separator: Option<StreetSeparator>,
635}
636
637impl Address for JosephineCountyAddress {
638    fn number(&self) -> i64 {
639        self.address_number
640    }
641
642    fn number_mut(&mut self) -> &mut i64 {
643        &mut self.address_number
644    }
645
646    fn number_suffix(&self) -> &Option<String> {
647        &self.address_number_suffix
648    }
649
650    fn number_suffix_mut(&mut self) -> &mut Option<String> {
651        &mut self.address_number_suffix
652    }
653
654    fn directional(&self) -> &Option<StreetNamePreDirectional> {
655        &self.street_name_pre_directional
656    }
657
658    fn directional_mut(&mut self) -> &mut Option<StreetNamePreDirectional> {
659        &mut self.street_name_pre_directional
660    }
661
662    fn street_name_pre_modifier(&self) -> &Option<StreetNamePreModifier> {
663        &self.street_name_pre_modifier
664    }
665
666    fn street_name_pre_modifier_mut(&mut self) -> &mut Option<StreetNamePreModifier> {
667        &mut self.street_name_pre_modifier
668    }
669
670    fn street_name_pre_type(&self) -> &Option<StreetNamePreType> {
671        &self.street_name_pre_type
672    }
673
674    fn street_name_pre_type_mut(&mut self) -> &mut Option<StreetNamePreType> {
675        &mut self.street_name_pre_type
676    }
677
678    fn street_name_separator(&self) -> &Option<StreetSeparator> {
679        &self.street_separator
680    }
681
682    fn street_name_separator_mut(&mut self) -> &mut Option<StreetSeparator> {
683        &mut self.street_separator
684    }
685
686    fn street_name(&self) -> &String {
687        &self.street_name
688    }
689
690    fn street_name_mut(&mut self) -> &mut String {
691        &mut self.street_name
692    }
693
694    fn street_type(&self) -> &Option<StreetNamePostType> {
695        &self.street_name_post_type
696    }
697
698    fn street_type_mut(&mut self) -> &mut Option<StreetNamePostType> {
699        &mut self.street_name_post_type
700    }
701
702    fn subaddress_id(&self) -> &Option<String> {
703        &self.subaddress_identifier
704    }
705
706    fn subaddress_id_mut(&mut self) -> &mut Option<String> {
707        &mut self.subaddress_identifier
708    }
709
710    fn subaddress_type(&self) -> &Option<SubaddressType> {
711        &self.subaddress_type
712    }
713
714    fn subaddress_type_mut(&mut self) -> &mut Option<SubaddressType> {
715        &mut self.subaddress_type
716    }
717
718    fn floor(&self) -> &Option<i64> {
719        &self.floor
720    }
721
722    fn floor_mut(&mut self) -> &mut Option<i64> {
723        &mut self.floor
724    }
725
726    fn building(&self) -> &Option<String> {
727        &None
728    }
729
730    fn building_mut(&mut self) -> &mut Option<String> {
731        &mut self.address_number_suffix
732    }
733
734    fn zip(&self) -> i64 {
735        self.zip_code
736    }
737
738    fn zip_mut(&mut self) -> &mut i64 {
739        &mut self.zip_code
740    }
741
742    fn postal_community(&self) -> &String {
743        &self.postal_community
744    }
745
746    fn postal_community_mut(&mut self) -> &mut String {
747        &mut self.postal_community
748    }
749
750    fn state(&self) -> &State {
751        &self.state_name
752    }
753
754    fn state_mut(&mut self) -> &mut State {
755        &mut self.state_name
756    }
757
758    fn status(&self) -> &AddressStatus {
759        &self.status
760    }
761
762    fn status_mut(&mut self) -> &mut AddressStatus {
763        &mut self.status
764    }
765}
766
767/// The `JosephineCountyAddresses` struct holds a vector of type
768/// ['JosephineCountyAddress'].
769#[derive(Debug, Default, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Deref, DerefMut)]
770pub struct JosephineCountyAddresses(Vec<JosephineCountyAddress>);
771
772impl Addresses<JosephineCountyAddress> for JosephineCountyAddresses {}
773
774impl IntoBin<JosephineCountyAddresses> for JosephineCountyAddresses {
775    fn load<P: AsRef<Path>>(path: P) -> Result<Self, AddressError> {
776        let config = bincode::config::standard();
777        match from_bin(path) {
778            Ok(records) => {
779                let (result, _) = bincode::serde::decode_from_slice::<
780                    Self,
781                    bincode::config::Configuration,
782                >(&records, config)
783                .map_err(|source| Decode::new(source, line!(), file!().into()))?;
784                Ok(result)
785            }
786            Err(source) => Err(AddressErrorKind::from(source).into()),
787        }
788    }
789
790    fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), AddressError> {
791        to_bin(self, path)
792    }
793}
794
795impl IntoCsv<JosephineCountyAddresses> for JosephineCountyAddresses {
796    fn from_csv<P: AsRef<Path>>(path: P) -> Result<Self, Io> {
797        let records = from_csv(path)?;
798        Ok(Self(records))
799    }
800
801    fn to_csv<P: AsRef<Path>>(&mut self, path: P) -> Result<(), AddressErrorKind> {
802        to_csv(&mut self.0, path.as_ref().into())
803    }
804}
805
806/// The `JosephineCountySpatialAddress` struct represents an address site point for Josephine County that includes geographic and projected coordinate information,
807/// prior to the schema adopted by the agency in April of 2024.
808#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Deserialize, Serialize)]
809pub struct JosephineCountySpatialAddress {
810    /// The `taxlot` field represents the map tax lot number of the parcel on which the address
811    /// is located.
812    #[serde(deserialize_with = "deserialize_arcgis_data")]
813    pub taxlot: Option<String>,
814    /// The `address_number` field represents the address number component of the complete address
815    /// number.
816    #[serde(rename = "stnum")]
817    pub address_number: i64,
818    /// The `address_number_suffix` field represents the address number suffix component of the complete
819    /// address number.
820    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "stnumsuf")]
821    pub address_number_suffix: Option<String>,
822    /// The `street_name_pre_directional` field represents the street name pre directional component of the
823    /// complete street name.
824    #[serde(
825        deserialize_with = "StreetNamePreDirectional::deserialize_abbreviated",
826        rename = "predir"
827    )]
828    pub street_name_pre_directional: Option<StreetNamePreDirectional>,
829    /// The `street_name` field represents the street name component of the complete street name.
830    #[serde(rename = "name")]
831    pub street_name: String,
832    /// The `street_name_post_type` field represents the street name post type component of the complete street
833    /// name.
834    #[serde(
835        // from abbreviated to mixed
836        deserialize_with = "StreetNamePostType::deserialize_mixed",
837        rename = "type"
838    )]
839    pub street_name_post_type: Option<StreetNamePostType>,
840    /// The `subaddress_type` field represents the subaddress type component of the complete
841    /// subaddress.
842    #[serde(
843        deserialize_with = "SubaddressType::deserialize_abbreviated",
844        rename = "unit_type"
845    )]
846    pub subaddress_type: Option<SubaddressType>,
847    /// The `subaddress_identifier` field represents the subaddress identifier component of the complete
848    /// subaddress.
849    #[serde(deserialize_with = "deserialize_arcgis_data", rename = "unit")]
850    pub subaddress_identifier: Option<String>,
851    /// The `floor` field represents the floor identifier, corresponding to the `Floor` field from the NENA standard.
852    #[serde(deserialize_with = "zero_floor")]
853    pub floor: Option<i64>,
854    /// The `complete_street_address` field represents the full street address as a string.
855    #[serde(rename = "address")]
856    pub complete_street_address: String,
857    /// The `postal_community` field represents the postal community component of the address,
858    /// being either the unincorporated or incorporated municipality name.
859    #[serde(rename = "postcomm")]
860    pub postal_community: String,
861    /// The `zip_code` field represents the postal zip code of the address.
862    #[serde(rename = "zip")]
863    pub zip_code: i64,
864    /// The `state_name` field represents the state name component of the address.
865    #[serde(deserialize_with = "State::deserialize_mixed")]
866    #[serde(rename = "state")]
867    pub state_name: State,
868    /// The `status` field represents the local status of the address as determined by the relevant
869    /// addressing authority.
870    pub status: AddressStatus,
871    /// The `x` field represents the cartesian X portion of the projected coordinates of the
872    /// address.
873    #[serde(rename = "point_x")]
874    pub x: f64,
875    /// The `y` field represents the cartesian Y portion of the projected coordinates of the
876    /// address.
877    #[serde(rename = "point_y")]
878    pub y: f64,
879    /// The `lat` field represents the latitude of the geographic coordinates for the address.
880    #[serde(rename = "latitude")]
881    pub lat: f64,
882    /// The `lon` field represents the longitude of the geographic coordinates for the address.
883    #[serde(rename = "longitude")]
884    pub lon: f64,
885    /// The `street_name_pre_modifier` field holds the pre-modifier element of the complete street
886    /// name.
887    #[serde(
888        deserialize_with = "StreetNamePreModifier::deserialize_mixed",
889        rename = "premod"
890    )]
891    pub street_name_pre_modifier: Option<StreetNamePreModifier>,
892    /// The `street_name_pre_type` field holds the pre-type element of the complete street
893    /// name.
894    #[serde(
895        deserialize_with = "StreetNamePreType::deserialize_mixed",
896        rename = "pretype"
897    )]
898    pub street_name_pre_type: Option<StreetNamePreType>,
899    /// The `street_separator` field holds the separator element of the complete street
900    /// name.
901    #[serde(
902        deserialize_with = "StreetSeparator::deserialize_mixed",
903        rename = "structdesc"
904    )]
905    pub street_separator: Option<StreetSeparator>,
906}
907
908impl Address for JosephineCountySpatialAddress {
909    fn number(&self) -> i64 {
910        self.address_number
911    }
912
913    fn number_mut(&mut self) -> &mut i64 {
914        &mut self.address_number
915    }
916
917    fn number_suffix(&self) -> &Option<String> {
918        &self.address_number_suffix
919    }
920
921    fn number_suffix_mut(&mut self) -> &mut Option<String> {
922        &mut self.address_number_suffix
923    }
924
925    fn directional(&self) -> &Option<StreetNamePreDirectional> {
926        &self.street_name_pre_directional
927    }
928
929    fn directional_mut(&mut self) -> &mut Option<StreetNamePreDirectional> {
930        &mut self.street_name_pre_directional
931    }
932
933    fn street_name_pre_modifier(&self) -> &Option<StreetNamePreModifier> {
934        &self.street_name_pre_modifier
935    }
936
937    fn street_name_pre_modifier_mut(&mut self) -> &mut Option<StreetNamePreModifier> {
938        &mut self.street_name_pre_modifier
939    }
940
941    fn street_name_pre_type(&self) -> &Option<StreetNamePreType> {
942        &self.street_name_pre_type
943    }
944
945    fn street_name_pre_type_mut(&mut self) -> &mut Option<StreetNamePreType> {
946        &mut self.street_name_pre_type
947    }
948
949    fn street_name_separator(&self) -> &Option<StreetSeparator> {
950        &self.street_separator
951    }
952
953    fn street_name_separator_mut(&mut self) -> &mut Option<StreetSeparator> {
954        &mut self.street_separator
955    }
956
957    fn street_name(&self) -> &String {
958        &self.street_name
959    }
960
961    fn street_name_mut(&mut self) -> &mut String {
962        &mut self.street_name
963    }
964
965    fn street_type(&self) -> &Option<StreetNamePostType> {
966        &self.street_name_post_type
967    }
968
969    fn street_type_mut(&mut self) -> &mut Option<StreetNamePostType> {
970        &mut self.street_name_post_type
971    }
972
973    fn subaddress_id(&self) -> &Option<String> {
974        &self.subaddress_identifier
975    }
976
977    fn subaddress_id_mut(&mut self) -> &mut Option<String> {
978        &mut self.subaddress_identifier
979    }
980
981    fn subaddress_type(&self) -> &Option<SubaddressType> {
982        &self.subaddress_type
983    }
984
985    fn subaddress_type_mut(&mut self) -> &mut Option<SubaddressType> {
986        &mut self.subaddress_type
987    }
988
989    fn floor(&self) -> &Option<i64> {
990        &self.floor
991    }
992
993    fn floor_mut(&mut self) -> &mut Option<i64> {
994        &mut self.floor
995    }
996
997    fn building(&self) -> &Option<String> {
998        &None
999    }
1000
1001    fn building_mut(&mut self) -> &mut Option<String> {
1002        &mut self.address_number_suffix
1003    }
1004
1005    fn zip(&self) -> i64 {
1006        self.zip_code
1007    }
1008
1009    fn zip_mut(&mut self) -> &mut i64 {
1010        &mut self.zip_code
1011    }
1012
1013    fn postal_community(&self) -> &String {
1014        &self.postal_community
1015    }
1016
1017    fn postal_community_mut(&mut self) -> &mut String {
1018        &mut self.postal_community
1019    }
1020
1021    fn state(&self) -> &State {
1022        &self.state_name
1023    }
1024
1025    fn state_mut(&mut self) -> &mut State {
1026        &mut self.state_name
1027    }
1028
1029    fn status(&self) -> &AddressStatus {
1030        &self.status
1031    }
1032
1033    fn status_mut(&mut self) -> &mut AddressStatus {
1034        &mut self.status
1035    }
1036}
1037
1038impl Cartesian for JosephineCountySpatialAddress {
1039    fn x(&self) -> f64 {
1040        self.x
1041    }
1042
1043    fn y(&self) -> f64 {
1044        self.y
1045    }
1046}
1047
1048impl Geographic for JosephineCountySpatialAddress {
1049    fn latitude(&self) -> f64 {
1050        self.lat
1051    }
1052
1053    fn longitude(&self) -> f64 {
1054        self.lon
1055    }
1056}
1057
1058/// The `JosephineCountySpatialAddresses` struct holds a vector of type
1059/// ['JosephineCountySpatialAddress'].
1060#[derive(Debug, Default, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Deref, DerefMut)]
1061pub struct JosephineCountySpatialAddresses(Vec<JosephineCountySpatialAddress>);
1062
1063impl Addresses<JosephineCountySpatialAddress> for JosephineCountySpatialAddresses {}
1064
1065impl IntoBin<JosephineCountySpatialAddresses> for JosephineCountySpatialAddresses {
1066    fn load<P: AsRef<Path>>(path: P) -> Result<Self, AddressError> {
1067        let config = bincode::config::standard();
1068        match from_bin(path) {
1069            Ok(records) => {
1070                let (results, _) = bincode::serde::decode_from_slice::<
1071                    Self,
1072                    bincode::config::Configuration,
1073                >(&records, config)
1074                .map_err(|source| Decode::new(source, line!(), file!().into()))?;
1075                Ok(results)
1076            }
1077            Err(source) => Err(AddressErrorKind::from(source).into()),
1078        }
1079    }
1080
1081    fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), AddressError> {
1082        to_bin(self, path)
1083    }
1084}
1085
1086impl IntoCsv<JosephineCountySpatialAddresses> for JosephineCountySpatialAddresses {
1087    fn from_csv<P: AsRef<Path>>(path: P) -> Result<Self, Io> {
1088        let records = from_csv(path)?;
1089        Ok(Self(records))
1090    }
1091
1092    fn to_csv<P: AsRef<Path>>(&mut self, path: P) -> Result<(), AddressErrorKind> {
1093        to_csv(&mut self.0, path.as_ref().into())
1094    }
1095}