From 010a42046596426e237fb3b0b7492404ee21d031 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Wed, 24 Nov 2021 09:59:00 -0600 Subject: [PATCH] Downgrade to 2018 edition (support rust-analyzer) --- Cargo.toml | 2 +- src/event.rs | 7 ++----- src/request.rs | 15 +-------------- 3 files changed, 4 insertions(+), 20 deletions(-) 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 {}