From 0bac2cbfc84898a5989cf39e8c249e3391800e0a Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Wed, 24 Nov 2021 14:29:31 -0600 Subject: [PATCH] Rename request mod to subscription --- src/lib.rs | 2 +- src/proto.rs | 14 ++++++-------- src/{request.rs => subscription.rs} | 0 3 files changed, 7 insertions(+), 9 deletions(-) rename src/{request.rs => subscription.rs} (100%) diff --git a/src/lib.rs b/src/lib.rs index a51deab..7fafd82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ pub mod error; pub mod event; pub mod proto; -pub mod request; +pub mod subscription; diff --git a/src/proto.rs b/src/proto.rs index 08f59ff..256f27f 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -1,5 +1,5 @@ use crate::error::{Error, Result}; -use crate::{event, request}; +use crate::{event, subscription}; use log::{debug, info}; use uuid::Uuid; @@ -31,15 +31,15 @@ impl Proto { #[derive(PartialEq, Debug)] pub enum NostrRawMessage { Event(String), - Req(String), + Sub(String), Close(String), } // A fully parsed request #[derive(PartialEq, Debug)] pub enum NostrRequest { - Event(event::Event), - Subscription(request::Subscription), + Ev(event::Event), + Sub(subscription::Subscription), } // Wrap the message in the expected request type @@ -48,7 +48,7 @@ fn msg_type_wrapper(msg: String) -> Result { if msg.starts_with(r#"["EVENT","#) { Ok(NostrRawMessage::Event(msg)) } else if msg.starts_with(r#"["REQ","#) { - Ok(NostrRawMessage::Req(msg)) + Ok(NostrRawMessage::Sub(msg)) } else if msg.starts_with(r#"["CLOSE","#) { Ok(NostrRawMessage::Close(msg)) } else { @@ -61,9 +61,7 @@ pub fn parse_type(msg: String) -> Result { let typ = msg_type_wrapper(msg)?; match typ { NostrRawMessage::Event(_) => Err(Error::EventParseFailed), - NostrRawMessage::Req(m) => Ok(NostrRequest::Subscription(request::Subscription::parse( - &m, - )?)), + NostrRawMessage::Sub(m) => Ok(NostrRequest::Sub(subscription::Subscription::parse(&m)?)), NostrRawMessage::Close(_) => Err(Error::CloseParseFailed), } } diff --git a/src/request.rs b/src/subscription.rs similarity index 100% rename from src/request.rs rename to src/subscription.rs