mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-14 23:19:07 -05:00
Downgrade to 2018 edition (support rust-analyzer)
This commit is contained in:
parent
bd7d083107
commit
010a420465
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nostr-rs-relay"
|
name = "nostr-rs-relay"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
@ -51,15 +51,14 @@ where
|
||||||
|
|
||||||
impl Event {
|
impl Event {
|
||||||
pub fn parse(json: &str) -> Result<Event> {
|
pub fn parse(json: &str) -> Result<Event> {
|
||||||
let e: Event = serde_json::from_str(json)?;
|
let _e: Event = serde_json::from_str(json)?;
|
||||||
Err(Error::EventParseFailed)
|
Err(Error::EventParseFailed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::event::Event;
|
use super::*;
|
||||||
use serde_json::Result;
|
|
||||||
fn simple_event() -> Event {
|
fn simple_event() -> Event {
|
||||||
super::Event {
|
super::Event {
|
||||||
id: 0,
|
id: 0,
|
||||||
|
@ -112,7 +111,6 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn event_deserialize() -> Result<()> {
|
fn event_deserialize() -> Result<()> {
|
||||||
let raw_json = r#"{"id":"1384757da583e6129ce831c3d7afc775a33a090578f888dd0d010328ad047d0c","pubkey":"bbbd9711d357df4f4e498841fd796535c95c8e751fa35355008a911c41265fca","created_at":1612650459,"kind":1,"tags":null,"content":"hello world","sig":"59d0cc47ab566e81f72fe5f430bcfb9b3c688cb0093d1e6daa49201c00d28ecc3651468b7938642869ed98c0f1b262998e49a05a6ed056c0d92b193f4e93bc21"}"#;
|
let raw_json = r#"{"id":"1384757da583e6129ce831c3d7afc775a33a090578f888dd0d010328ad047d0c","pubkey":"bbbd9711d357df4f4e498841fd796535c95c8e751fa35355008a911c41265fca","created_at":1612650459,"kind":1,"tags":null,"content":"hello world","sig":"59d0cc47ab566e81f72fe5f430bcfb9b3c688cb0093d1e6daa49201c00d28ecc3651468b7938642869ed98c0f1b262998e49a05a6ed056c0d92b193f4e93bc21"}"#;
|
||||||
|
|
||||||
// id: 1384757da583e6129ce831c3d7afc775a33a090578f888dd0d010328ad047d0c
|
// id: 1384757da583e6129ce831c3d7afc775a33a090578f888dd0d010328ad047d0c
|
||||||
// pubkey: bbbd9711d357df4f4e498841fd796535c95c8e751fa35355008a911c41265fca",
|
// pubkey: bbbd9711d357df4f4e498841fd796535c95c8e751fa35355008a911c41265fca",
|
||||||
// created_at: 1612650459
|
// created_at: 1612650459
|
||||||
|
@ -120,7 +118,6 @@ mod tests {
|
||||||
// tags":null,
|
// tags":null,
|
||||||
// "content":"hello world",
|
// "content":"hello world",
|
||||||
// "sig":"59d0cc47ab566e81f72fe5f430bcfb9b3c688cb0093d1e6daa49201c00d28ecc3651468b7938642869ed98c0f1b262998e49a05a6ed056c0d92b193f4e93bc21"}]"#;
|
// "sig":"59d0cc47ab566e81f72fe5f430bcfb9b3c688cb0093d1e6daa49201c00d28ecc3651468b7938642869ed98c0f1b262998e49a05a6ed056c0d92b193f4e93bc21"}]"#;
|
||||||
|
|
||||||
let e: Event = serde_json::from_str(raw_json)?;
|
let e: Event = serde_json::from_str(raw_json)?;
|
||||||
// assert that the kind is 1
|
// assert that the kind is 1
|
||||||
assert_eq!(e.kind, 1);
|
assert_eq!(e.kind, 1);
|
||||||
|
|
|
@ -7,18 +7,7 @@ use serde::{Deserialize, Deserializer, Serialize};
|
||||||
// Container for a request filter
|
// Container for a request filter
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
pub struct ReqCmd {
|
pub struct ReqCmd {
|
||||||
|
cmds: Vec<String>
|
||||||
#[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<Vec<String>>,
|
|
||||||
content: String,
|
|
||||||
#[serde(deserialize_with = "u64_from_string")]
|
|
||||||
sig: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
|
@ -39,5 +28,3 @@ pub struct ReqFilter {
|
||||||
since: Option<u64>,
|
since: Option<u64>,
|
||||||
authors: Option<Vec<String>>,
|
authors: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Request {}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user