Enum nostr::message::relay::RelayMessage
source · pub enum RelayMessage {
Event {
subscription_id: SubscriptionId,
event: Box<Event>,
},
Ok {
event_id: EventId,
status: bool,
message: String,
},
EndOfStoredEvents(SubscriptionId),
Notice {
message: String,
},
Closed {
subscription_id: SubscriptionId,
message: String,
},
Auth {
challenge: String,
},
Count {
subscription_id: SubscriptionId,
count: usize,
},
NegMsg {
subscription_id: SubscriptionId,
message: String,
},
NegErr {
subscription_id: SubscriptionId,
code: NegentropyErrorCode,
},
}Expand description
Messages sent by relays, received by clients
Variants§
Event
["EVENT", <subscription_id>, <event JSON>] (NIP01)
Ok
["OK", <event_id>, <true|false>, <message>] (NIP01)
EndOfStoredEvents(SubscriptionId)
["EOSE", <subscription_id>] (NIP01)
Notice
[“NOTICE”, <message>] (NIP01)
Closed
["CLOSED", <subscription_id>, <message>] (NIP01)
Auth
["AUTH", <challenge-string>] (NIP42)
Count
["COUNT", <subscription_id>, {"count": <integer>}] (NIP45)
NegMsg
Negentropy Message
NegErr
Negentropy Error
Implementations§
source§impl RelayMessage
impl RelayMessage
sourcepub fn new_event(subscription_id: SubscriptionId, event: Event) -> Self
pub fn new_event(subscription_id: SubscriptionId, event: Event) -> Self
Create new EVENT message
sourcepub fn new_notice<S>(message: S) -> Self
pub fn new_notice<S>(message: S) -> Self
Create new NOTICE message
sourcepub fn new_closed<S>(subscription_id: SubscriptionId, message: S) -> Self
pub fn new_closed<S>(subscription_id: SubscriptionId, message: S) -> Self
Create new CLOSED message
sourcepub fn new_eose(subscription_id: SubscriptionId) -> Self
pub fn new_eose(subscription_id: SubscriptionId) -> Self
Create new EOSE message
sourcepub fn new_count(subscription_id: SubscriptionId, count: usize) -> Self
pub fn new_count(subscription_id: SubscriptionId, count: usize) -> Self
Create new EVENT message
sourcepub fn from_value(msg: Value) -> Result<Self, MessageHandleError>
pub fn from_value(msg: Value) -> Result<Self, MessageHandleError>
Deserialize RelayMessage from Value
Trait Implementations§
source§impl Clone for RelayMessage
impl Clone for RelayMessage
source§fn clone(&self) -> RelayMessage
fn clone(&self) -> RelayMessage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for RelayMessage
impl Debug for RelayMessage
source§impl<'de> Deserialize<'de> for RelayMessage
impl<'de> Deserialize<'de> for RelayMessage
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Hash for RelayMessage
impl Hash for RelayMessage
source§impl JsonUtil for RelayMessage
impl JsonUtil for RelayMessage
source§impl Ord for RelayMessage
impl Ord for RelayMessage
source§fn cmp(&self, other: &RelayMessage) -> Ordering
fn cmp(&self, other: &RelayMessage) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for RelayMessage
impl PartialEq for RelayMessage
source§fn eq(&self, other: &RelayMessage) -> bool
fn eq(&self, other: &RelayMessage) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd for RelayMessage
impl PartialOrd for RelayMessage
source§fn partial_cmp(&self, other: &RelayMessage) -> Option<Ordering>
fn partial_cmp(&self, other: &RelayMessage) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl Serialize for RelayMessage
impl Serialize for RelayMessage
source§impl TryFrom<RawRelayMessage> for RelayMessage
impl TryFrom<RawRelayMessage> for RelayMessage
§type Error = MessageHandleError
type Error = MessageHandleError
The type returned in the event of a conversion error.
impl Eq for RelayMessage
impl StructuralEq for RelayMessage
impl StructuralPartialEq for RelayMessage
Auto Trait Implementations§
impl RefUnwindSafe for RelayMessage
impl Send for RelayMessage
impl Sync for RelayMessage
impl Unpin for RelayMessage
impl UnwindSafe for RelayMessage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.