From b27b38014e02793e36dc96b9092052bd8952cf36 Mon Sep 17 00:00:00 2001 From: Alex Wright Date: Mon, 10 Oct 2022 00:17:05 +0100 Subject: [PATCH] Added an enum for Country --- src/main.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index a3acab2..2c2b080 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,12 +4,25 @@ use rust_decimal::Decimal; use std::error::Error; use std::io; use std::path::Path; -use std::process; use std::str::FromStr; use serde::{Deserialize, Serialize}; use serde; 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)] #[serde(rename_all = "lowercase")] enum Status { @@ -56,7 +69,7 @@ struct Postcode { #[serde(deserialize_with = "csv::invalid_option")] northing: Option, positional_quality_indicator: PositionalQuality, - country: String, + country: Country, latitude: Option, longitude: Option, postcode_no_space: String, @@ -75,7 +88,7 @@ struct SmolPostcode { status: Status, usertype: UserType, positional_quality_indicator: PositionalQuality, - country: String, + country: Country, latitude: Option, longitude: Option, }