mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-14 15:09:07 -05:00
Rename request mod to subscription
This commit is contained in:
parent
0b7742cfb1
commit
0bac2cbfc8
|
@ -1,4 +1,4 @@
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod proto;
|
pub mod proto;
|
||||||
pub mod request;
|
pub mod subscription;
|
||||||
|
|
14
src/proto.rs
14
src/proto.rs
|
@ -1,5 +1,5 @@
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::{event, request};
|
use crate::{event, subscription};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
@ -31,15 +31,15 @@ impl Proto {
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub enum NostrRawMessage {
|
pub enum NostrRawMessage {
|
||||||
Event(String),
|
Event(String),
|
||||||
Req(String),
|
Sub(String),
|
||||||
Close(String),
|
Close(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
// A fully parsed request
|
// A fully parsed request
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub enum NostrRequest {
|
pub enum NostrRequest {
|
||||||
Event(event::Event),
|
Ev(event::Event),
|
||||||
Subscription(request::Subscription),
|
Sub(subscription::Subscription),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap the message in the expected request type
|
// Wrap the message in the expected request type
|
||||||
|
@ -48,7 +48,7 @@ fn msg_type_wrapper(msg: String) -> Result<NostrRawMessage> {
|
||||||
if msg.starts_with(r#"["EVENT","#) {
|
if msg.starts_with(r#"["EVENT","#) {
|
||||||
Ok(NostrRawMessage::Event(msg))
|
Ok(NostrRawMessage::Event(msg))
|
||||||
} else if msg.starts_with(r#"["REQ","#) {
|
} else if msg.starts_with(r#"["REQ","#) {
|
||||||
Ok(NostrRawMessage::Req(msg))
|
Ok(NostrRawMessage::Sub(msg))
|
||||||
} else if msg.starts_with(r#"["CLOSE","#) {
|
} else if msg.starts_with(r#"["CLOSE","#) {
|
||||||
Ok(NostrRawMessage::Close(msg))
|
Ok(NostrRawMessage::Close(msg))
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,9 +61,7 @@ pub fn parse_type(msg: String) -> Result<NostrRequest> {
|
||||||
let typ = msg_type_wrapper(msg)?;
|
let typ = msg_type_wrapper(msg)?;
|
||||||
match typ {
|
match typ {
|
||||||
NostrRawMessage::Event(_) => Err(Error::EventParseFailed),
|
NostrRawMessage::Event(_) => Err(Error::EventParseFailed),
|
||||||
NostrRawMessage::Req(m) => Ok(NostrRequest::Subscription(request::Subscription::parse(
|
NostrRawMessage::Sub(m) => Ok(NostrRequest::Sub(subscription::Subscription::parse(&m)?)),
|
||||||
&m,
|
|
||||||
)?)),
|
|
||||||
NostrRawMessage::Close(_) => Err(Error::CloseParseFailed),
|
NostrRawMessage::Close(_) => Err(Error::CloseParseFailed),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user