Enum nostr_sdk::RelayMessage
source · pub enum RelayMessage {
Event {
subscription_id: SubscriptionId,
event: Box<Event, Global>,
},
Ok {
event_id: EventId,
status: bool,
message: String,
},
EndOfStoredEvents(SubscriptionId),
Notice {
message: String,
},
Auth {
challenge: String,
},
Count {
subscription_id: SubscriptionId,
count: usize,
},
}
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)
Auth
["AUTH", <challenge-string>]
(NIP42)
Count
["COUNT", <subscription_id>, {"count": <integer>}]
(NIP45)
Implementations§
source§impl RelayMessage
impl RelayMessage
sourcepub fn new_event(subscription_id: SubscriptionId, event: Event) -> RelayMessage
pub fn new_event(subscription_id: SubscriptionId, event: Event) -> RelayMessage
Create new EVENT
message
sourcepub fn new_notice<S>(message: S) -> RelayMessagewhere
S: Into<String>,
pub fn new_notice<S>(message: S) -> RelayMessagewhere S: Into<String>,
Create new NOTICE
message
sourcepub fn new_eose(subscription_id: SubscriptionId) -> RelayMessage
pub fn new_eose(subscription_id: SubscriptionId) -> RelayMessage
Create new EOSE
message
sourcepub fn new_ok<S>(event_id: EventId, status: bool, message: S) -> RelayMessagewhere
S: Into<String>,
pub fn new_ok<S>(event_id: EventId, status: bool, message: S) -> RelayMessagewhere S: Into<String>,
Create new OK
message
sourcepub fn new_auth<S>(challenge: S) -> RelayMessagewhere
S: Into<String>,
pub fn new_auth<S>(challenge: S) -> RelayMessagewhere S: Into<String>,
Create new AUTH
message
sourcepub fn new_count(subscription_id: SubscriptionId, count: usize) -> RelayMessage
pub fn new_count(subscription_id: SubscriptionId, count: usize) -> RelayMessage
Create new EVENT
message
sourcepub fn as_json(&self) -> String
pub fn as_json(&self) -> String
Serialize RelayMessage
as JSON string
sourcepub fn from_value_with_ctx<C>(
secp: &Secp256k1<C>,
msg: Value
) -> Result<RelayMessage, MessageHandleError>where
C: Verification,
pub fn from_value_with_ctx<C>( secp: &Secp256k1<C>, msg: Value ) -> Result<RelayMessage, MessageHandleError>where C: Verification,
Deserialize RelayMessage
from Value
sourcepub fn from_json<S>(msg: S) -> Result<RelayMessage, MessageHandleError>where
S: Into<String>,
pub fn from_json<S>(msg: S) -> Result<RelayMessage, MessageHandleError>where S: Into<String>,
Deserialize RelayMessage
as JSON string
sourcepub fn from_json_with_ctx<C, S>(
secp: &Secp256k1<C>,
msg: S
) -> Result<RelayMessage, MessageHandleError>where
C: Verification,
S: Into<String>,
pub fn from_json_with_ctx<C, S>( secp: &Secp256k1<C>, msg: S ) -> Result<RelayMessage, MessageHandleError>where C: Verification, S: Into<String>,
Deserialize RelayMessage
as JSON string
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<RelayMessage, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>( deserializer: D ) -> Result<RelayMessage, <D as Deserializer<'de>>::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 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<RelayMessage> for RelayMessage
impl PartialEq<RelayMessage> 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<RelayMessage> for RelayMessage
impl PartialOrd<RelayMessage> 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§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
Serialize this value into the given Serde serializer. Read more
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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.