diff --git a/Cargo.toml b/Cargo.toml index 03f8ee3..5aa20cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nostr-rs-relay" version = "0.1.0" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/event.rs b/src/event.rs index 5e21fbd..1bdb191 100644 --- a/src/event.rs +++ b/src/event.rs @@ -51,15 +51,14 @@ where impl Event { pub fn parse(json: &str) -> Result { - let e: Event = serde_json::from_str(json)?; + let _e: Event = serde_json::from_str(json)?; Err(Error::EventParseFailed) } } #[cfg(test)] mod tests { - use crate::event::Event; - use serde_json::Result; + use super::*; fn simple_event() -> Event { super::Event { id: 0, @@ -112,7 +111,6 @@ mod tests { #[test] fn event_deserialize() -> Result<()> { let raw_json = r#"{"id":"1384757da583e6129ce831c3d7afc775a33a090578f888dd0d010328ad047d0c","pubkey":"bbbd9711d357df4f4e498841fd796535c95c8e751fa35355008a911c41265fca","created_at":1612650459,"kind":1,"tags":null,"content":"hello world","sig":"59d0cc47ab566e81f72fe5f430bcfb9b3c688cb0093d1e6daa49201c00d28ecc3651468b7938642869ed98c0f1b262998e49a05a6ed056c0d92b193f4e93bc21"}"#; - // id: 1384757da583e6129ce831c3d7afc775a33a090578f888dd0d010328ad047d0c // pubkey: bbbd9711d357df4f4e498841fd796535c95c8e751fa35355008a911c41265fca", // created_at: 1612650459 @@ -120,7 +118,6 @@ mod tests { // tags":null, // "content":"hello world", // "sig":"59d0cc47ab566e81f72fe5f430bcfb9b3c688cb0093d1e6daa49201c00d28ecc3651468b7938642869ed98c0f1b262998e49a05a6ed056c0d92b193f4e93bc21"}]"#; - let e: Event = serde_json::from_str(raw_json)?; // assert that the kind is 1 assert_eq!(e.kind, 1); diff --git a/src/request.rs b/src/request.rs index f057780..2afa416 100644 --- a/src/request.rs +++ b/src/request.rs @@ -7,18 +7,7 @@ use serde::{Deserialize, Deserializer, Serialize}; // Container for a request filter #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct ReqCmd { - - #[serde(deserialize_with = "u32_from_string")] - id: u32, - #[serde(deserialize_with = "u32_from_string")] - pubkey: u32, - created_at: u64, - kind: u8, - #[serde(deserialize_with = "tag_from_string")] - tags: Vec>, - content: String, - #[serde(deserialize_with = "u64_from_string")] - sig: u64, + cmds: Vec } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] @@ -39,5 +28,3 @@ pub struct ReqFilter { since: Option, authors: Option>, } - -pub struct Request {}