Added an enum for Country
This commit is contained in:
parent
f52d2d06ec
commit
b27b38014e
19
src/main.rs
19
src/main.rs
|
@ -4,12 +4,25 @@ use rust_decimal::Decimal;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde;
|
use serde;
|
||||||
use serde_repr::*;
|
use serde_repr::*;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
enum Country {
|
||||||
|
England,
|
||||||
|
Scotland,
|
||||||
|
Wales,
|
||||||
|
NorthernIreland,
|
||||||
|
|
||||||
|
#[serde(rename="Isle of Man")]
|
||||||
|
IsleOfMan,
|
||||||
|
|
||||||
|
#[serde(rename="Channel Islands")]
|
||||||
|
ChannelIslands,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
enum Status {
|
enum Status {
|
||||||
|
@ -56,7 +69,7 @@ struct Postcode {
|
||||||
#[serde(deserialize_with = "csv::invalid_option")]
|
#[serde(deserialize_with = "csv::invalid_option")]
|
||||||
northing: Option<u32>,
|
northing: Option<u32>,
|
||||||
positional_quality_indicator: PositionalQuality,
|
positional_quality_indicator: PositionalQuality,
|
||||||
country: String,
|
country: Country,
|
||||||
latitude: Option<String>,
|
latitude: Option<String>,
|
||||||
longitude: Option<String>,
|
longitude: Option<String>,
|
||||||
postcode_no_space: String,
|
postcode_no_space: String,
|
||||||
|
@ -75,7 +88,7 @@ struct SmolPostcode {
|
||||||
status: Status,
|
status: Status,
|
||||||
usertype: UserType,
|
usertype: UserType,
|
||||||
positional_quality_indicator: PositionalQuality,
|
positional_quality_indicator: PositionalQuality,
|
||||||
country: String,
|
country: Country,
|
||||||
latitude: Option<Decimal>,
|
latitude: Option<Decimal>,
|
||||||
longitude: Option<Decimal>,
|
longitude: Option<Decimal>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue