From 6abf3e97a5552b0305eeb6a1b8748414f4df24ae Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 8 Jul 2024 11:21:47 +0200 Subject: Update parsing of PhishTank data files. - Remove special handling of the `phish_id` field in the Phish struct. The source json files now represents the id as a number. - Remove `country` field from PhishDetails. No longer supplied in the json data set. - Rename `verified_time` to `verification_time` in the Phish struct, to match the names used in the data set. --- src/lib.rs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 8f56601..043f485 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,6 @@ pub struct PhishTank { #[derive(Deserialize)] pub struct Phish { - #[serde(deserialize_with = "deserialize_number")] pub phish_id: u64, pub url: String, pub phish_detail_url: String, @@ -36,7 +35,7 @@ pub struct Phish { #[serde(deserialize_with = "deserialize_yesno")] pub verified: bool, - pub verified_time: Option>, + pub verification_time: Option>, #[serde(deserialize_with = "deserialize_yesno")] pub online: bool, @@ -50,7 +49,6 @@ pub struct PhishDetails { pub cidr_block: String, pub announcing_network: String, pub rir: String, - pub country: String, pub detail_time: DateTime, } @@ -66,18 +64,6 @@ impl PhishTank { } } -// Helper function to deserialize a number represented as a string. -// -// The PhishTank dataset represents numbers this way, so the default -// json deserializer implementation will only deserialize to a string. -// -fn deserialize_number<'de, D>(d: D) -> Result - where D: Deserializer<'de> -{ - let s = String::deserialize(d)?; - u64::from_str(&s).map_err(serde::de::Error::custom) -} - // Helper function to deserialize "yes/no" into a bool. // // The PhishTank dataset uses the strings "yes" and "no" to represent -- cgit v1.2.3